You can use the cos function to find the x coordinate with the correct angle phi . First of all, we note that the angle between the radius that intersects the vertex phi has an angle with x-axis defined by the expression:

and the x coordinate of this vertex is given by

therefore, the mask just needs to set this line to 3.
Example:
phi = 45; % Desired angle in degrees width = 350; % Desired width in pixels height = 50; % Desired height of bar in pixels theta = pi-phi*pi/180; % The radius angle x = centerX + round(radius*cos(theta)); % Find the nearest row x0 = max(1, x-height); % Find where to start the bar Img(x0:x,1:width)=3;
The resulting image looks like this: 
Please note that the max function is used to consider the case when the thickness of the bar will extend beyond the top of the image.
Regarding resolution, image resolution is determined by the size of the matrix being created. In your example, this is (400,300). If you want a higher resolution just increase these numbers. However, if you want to associate a resolution with a higher DPI (dots per inch) so that there are more pixels on each physical inch, you can use the Export Settings window on the File menu.
Shown here: 
source share