Matlab running minimised using task scheduler influences image plots

5 views (last 30 days)
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 Comments
Rahul
Rahul on 7 Aug 2024
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.

Sign in to comment.

Answers (2)

Rahul
Rahul on 9 Aug 2024
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 on 10 Sep 2024
Moved: Walter Roberson on 10 Sep 2024
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

Categories

Find more on Desktop in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!