Export picture gets cut off - How does Matlab export pictures? [new idea for origin of the error]

22 views (last 30 days)
Hello,
I have a problem with exporting images. We are working together on a project and therefore on different Matlab versions and PCs.
In my program the code runs through correctly and generates the desired image (image 1). This works on my PC (Matlab 2020a) and on my account on the Virtual Machine.On my colleague, the image is clipped even though he is using the same VM with the same Matlab (image 2). (Matlab 2019b)
I already tried to use his config from "prefdir" with my Matlab on the VM, but I get the correct image there too.
On my first run on the VM the opened image in Paint was cropped exactly the same but could be displayed completely by dragging the program frame. This does not work with my colleague.
I cut the image at the end of the code before saving it, but I dont think that this is the problem.
% cut the mainfig
newWidth = SubplotRight(1)+ SubplotRight(3) + 100; % get right width of image
set(gcf,'color','w');
F = getframe(mainfig); % get frame of figure
ImageSize = size(F.cdata); % get length of figure
F.cdata(:,newWidth:ImageSize(2),:) = []; % delete empty pixel
% save as png
fName = [subject.OutputDirectory '\' subject.name '_Brain activity over entire stimulus period.png'];
imwrite(F.cdata, fName, 'png');
% close figure
close
Thanks for helping!
EDIT:
After further research I found a possible reason for the error.The only difference between my colleague and me in terms of setup is that I have a larger main screen + another screen.
When running the program, the position of the image should be set to a certain value. However, this does not seem to be accepted by Matlab.
Here you can see that Matlab doesnt use the sizex value of 135000 and instead sets it to 3844 (screen resolution combined of both of my screens)
If I'm right this function would be a workaround:
Is there another way to let Matlab just use a custome position even without having the space on real screens or is this MEX function needed?
We also noticed that the screen has an influence on the position - but not on exporting the image.
My colleague used Matlab with his laptop and a second screen. On the laptop screen sizex was set to 1480, on the second screen to sizex = 1920. Nevertheless, when exporting the image using the second screen for matlab, the image was still cropped even though sizex was set to 1920.
We assume that this is related to the main laptop screen - is this correct?
Again, Thanks for helping!

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!