Matlab running minimised using task scheduler influences image plots

조회 수: 5 (최근 30일)
Jonathan
Jonathan 2024년 7월 29일
이동: Walter Roberson 2024년 9월 10일
Hi, I have been running a matlab script on a daily basis using windows task scheduler for the past few weeks and have noticed that the output image plots appear compressed (the arrows and contours are squished together, implying some sort of scale issue(?)) when compared with running the same script with matlab already running on my desktop. My script does specify the dimensions of the figure, but these seem to be ignored. Is there a way to correct for this? Related, if I can resolve the former issues, is there a way to force Task Scheduler to run matlab so that it is maximised (not behind the scene).
I'm using the following in Task scheduler to initiate my script:
matlab -r "cd('C:\MatlabScripts\'); run scriptname.m; pause(10)"
Thank you for any thoughts on this,
Jon
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 7월 30일
Does your script specify the PaperSize property for the figure ?
Rahul
Rahul 2024년 8월 7일
Hey @Jonathan, can you provide your MATLAB release version, and preferrably the script that is being run. That could help me address the exact issue.

댓글을 달려면 로그인하십시오.

답변 (2개)

Rahul
Rahul 2024년 8월 9일
Hi Jonathan,
I am unable to reproduce this issue, in the latest R2024a release of MATLAB, using the commands specified in the question.
Although, you can refer to this previously documented question regarding task scheduling of scripts in MATLAB:
You can refer to the following code snippet of a MATLAB script that shows an image and plot as subplots in a figure with a custom position used, which seems to be working fine without any compression:
% Reading an image file
im = imread('full_path_to_image');
% Initializing a figure
f = figure('Position',[200 200 600 500]);
% Plotting on the same figure
subplot(2, 1, 1);
imshow(im);
% Plotting as second subfigure
subplot(2, 1, 2);
% Line Plot of a random vector
plot(rand(1, 255));
Subsequently, you can have the MATLAB window run in the background as minimized or maximized by checking or unchecking the ‘Hidden’ Toggle Button in the properties of your scheduled task (in case of Windows 11), respectively:
For further information regarding scheduling tasks related to MATLAB scripts and functions you can refer to similar questions in the MATLAB Answers Community:
Hope this helps!

Jonathan
Jonathan 2024년 9월 10일
이동: Walter Roberson 2024년 9월 10일
Apologies for not responding sooner, I am running this in R2022b. After a lot of searching on the web, I was able to narrow it down to a specific setting in the windows task scheduler. Under the general tab, I had the "Run whether user is logged on or not" selected, which forced matlab to run in the background. In doing this, it affected how the plots were being produced, which were more compressed. When I changed the setting to "Run only when user is logged on", matlab would run in the foreground and the plots were produced correctly; i.e., my plot script would adhere to the prespecified figure dimensions included in my script. Hope this helps.
Thanks
Jon

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by