MATLAB: Matlab figure saving dim

figure

has anyone observed that if a matlab figure is saved as a jpg, its dimension in the jpg changes. is this true?
I have two images and the description is below :
img A -> .fig size = 638x816x3 || .jpg size = 733x988x3
img B -> .fig size = 638x816x3 || .jpg size = 963x1904x3
it seems that there is some scaling done while saving images as jpg. Further, the scaling doesn't seem to be generalized since the sizes of my .fig files are the same but the output jpgs are different.
Pls explain how to save with same dimensions.

Best Answer

It seems that you are trying to save an image matrix as a jpeg. saveas() is not the correct function if you want to preserve the resolution of your image. Use imwrite(): https://www.mathworks.com/help/releases/R2020a/matlab/ref/imwrite.html
saveas does not recognize that there is an image present in the figure window. It merely rasterizes all the content of your figure and saves it as an image.