How can I set the default figure size to full screen for use with a parfor loop?
61 ビュー (過去 30 日間)
古いコメントを表示
I am modeling objects in flow with various orientations and animating the results using the movie command. I am storing figure frames for every loop iteration and then playing them back at the end. This works great for simple flows and few orientations, but takes a very long time for larger data sets (~20 minutes for approximately 80 orientations of an airfoil). I can cut down this time significantly using a parallel pool, but the issue that arises is that parfor will size the animation window to the the default figure size. I created a new full screen figure using
figure('units', 'normalized', 'outerposition', [0 0 1 1])
outside the loop and
set(gcf,'units','normalized','outerposition',[0 0 1 1])
inside the loop
however, when running the movie after calculations, every other run was still the default figure size. If I could set the default window size to full screen I believe it would solve the problem. I have attached the loop that gathers frames below.
note: I do realize that parfor is not great for this purpose, as it is non-sequential and may cause a mixup in the order of my frames. However, these effects have been negligible in my previous runs and the slight quality reduction will be worth the time savings for me.
close all
figure('units','normalized','outerposition',[0 0 1 1])
for i = 1:length(alpha)
levelAlpha = find(alpha == alpha(i)); %getting angle of attack
srcStrengths = ss(levelAlpha, :); %getting source Strengths
vortStrengths = sv(levelAlpha, :); %getting vortex Strengths
hold on
[hp, coords] = hessPlot(uinf, alpha(i), xCords, yCords, srcStrengths, vortStrengths, 'both', 1); %plotting use custom flow superposition function
title(['Hess-Smith Visualization for ', airfoil]);
patch(coords(:, 1), coords(:, 2), [.8 .8 .8]);
set(gcf,'units','normalized','outerposition',[0 0 1 1])
set(gcf, 'visible', 'off')
box on
legend(sprintf('\\alpha = %.1f^{\\circ}', alpha(i)))
frames(i) = getframe(gcf); %getting Frames
clf %clearing Figure
end
set(gcf, 'visible', 'on')
I appreciate any help that you can provide!
0 件のコメント
回答 (1 件)
Kevin Gleason
2017 年 5 月 3 日
You can set the default size of a figure by modifying the following default properties of the Graphics Root object:
>> set(groot, 'defaultFigureUnits','normalized')
>> set(groot, 'defaultFigurePosition',[0 0 1 1])
All figures created after this point will be full-screen.
It might also be worth it to create an array of figures to do this work, so that each worker will have its own figure to modify:
% Init Figures:
numWorkers = 2;
figNums = zeros(numWorkers,1);
for i=1:numWorkers
fig = figure;
fig.Position = [0 0 1 1];
figNums (i) = fig;
end
parfor i=1:10
figIdx = mod(i,numWorkers)+1; % index of figure to modify
fig = figure(figNums(figIdx)); % Figure to Modify
end
Default Values Reference: https://www.mathworks.com/help/matlab/creating_plots/default-property-values.html
参考
カテゴリ
Help Center および File Exchange で Array Geometries and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!