Figure size when run from task scheduler
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear community,
I would like to have a figure that is updated every midnight. So, I boot my computer automatically from the BIOS. Next, there are two scripts in the windows 10 task scheduler that are executed some time later with the setting: 'whether the user is logged on or not'. The first one scrapes some data and works absolutely fine. The second one starts the script, plots the figure, which works fine as well, except for the figure window size. The window size is as desired when I manually run the script with Matlab opened though!
The problem: The figure size should be about screen size (as give by 'position'), but is still Matlab default. In task manager the 'hidden' function is not selected. Matlab is not started with '-minimize -r', just '-r'. Alse, the program has highest privilages.
What I tried/investigated already: I have tried visible 'on', draw now, pause(5) to no avail. When the program is running still, and I log in on my computer, Matlab is running as a background process (which I think is core of the problem).
What I would like to have: primarily a solution to the figure position. Secondarily, the source of the problem and the mechanism of the solution for other Matlab users.
Code:
My_Plot = figure('visible','off','Renderer','Painters','Position',[1 41 1920 963]);
hold on
% the plot itself and the adjustments of the axis all come out the way it
% should be, except for the figure position.
draw now
pause(5); % or 0.02, but 5 doesn't do the trick
ax = gca;
ax.Position = [0.066 0.041 0.868 0.882];
hold off
draw now
pause(5);
Sincerely,
Max
edit(fixed typo's in the code after Jan's comment)
0 comentarios
Respuestas (1)
Jan
el 12 de Mzo. de 2021
Editada: Jan
el 12 de Mzo. de 2021
Is this really your code?
My_Plot = figure('visible','off','Renderer','Painters', ...
'Position','[1 41 1920 963]')
% ^ ??? ^ ???
No quotes here.
draw now ???
% Do you mean:
drawnow
You code fails here also:
ax.Position = [0.066 0.041 0.868 0.882];
% Undefined variable "ax"!
If nothing help and this is really true: "but is still Matlab default", then simply adjust Matlab's default:
set(groot, 'DefaultFigurePosition', [1 41 1920 963]);
Remember, that Matlab does not create figures larger than the screen. At least this was the case from Matlab 4.0 to 2018b. If I need this, I use: https://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi
I assume the lower position 41 is inside the taskbar and rejected for this reason. But then this would not happen: "The window size is as desired when I manually run the script with Matlab opened though!"
2 comentarios
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!