@Jan: thanks for your answer and hint how to answer. I'll try to do so.
I will attach a strongly reduced code only to show the flowgraph of the program. This reduced code is not running! The function "processing" is called with a dedicated set of data.
function [out1, out2] = processing(in1, in2, in3)
After some lines of code filenames and the figures are initialized by:
if(Plot)
.
.
filename_fig2 = [directory '\References\Adata'];
filename_fig3 = [directory '\References\Bdata'];
fh2 = figure(2);
clf(fh2,'reset');
set(fh2,'Position',[22 80 393 420]);
set(fh2,'Name','Average A per proc. step');
set(fh2,'Visible','off')
fh3 = figure(3);
clf(fh3,'reset');
set(fh3,'Position',[428 80 393 420]);
set(fh3,'Name','Average A per proc. step');
set(fh3,'Visible','off')
.
.
.
.
.
end
Next comes the loop with the proceesing of data, which a read from file.
k = 0;
for current_data = start_data:last_data
.
.
.
k = k + 1;
--- compute current time ---
t = (k-1) * dt;
--- call processing ---
[datalist,varlist] = processing_control(var1, varn);
end
After the complete set of data has been processed, some results
are plot, using:
if(Plot)
--- prepare title ---
sa = sprintf('bla, bla, bla');
set(fh2,'Visible','on')
--- plot information ---
figure(fh2);
subplot(211)
plot(datalist.A);grid on
ylabel('Avg A]')
title(sa)
subplot(212)
plot(datalist.B);grid on
xlabel('proc step')
ylabel('Avg B]')
.
.
.
.
.
saveas(fh2,filename_fig2,'jpg');
fprintf(1,' --> Saved %s.jpg\n',filename_fig2);
saveas(fh3,filename_fig3,'jpg');
fprintf(1,' --> Saved %s.jpg\n',filename_fig3);
delete(fh2);
delete(fh3);
.
.
.
.
end
Finally in the current version all remaining figures are deleted by:
h = findobj(findobj,'-depth',0,'Type','Figure');
if(~isempty(h))
for lh=1:length(h)
delete(h(lh));
end
end
Last the end of the function by:
end
The function processing_control calls another function, which process a sub-set of data and plots some results within 3 figures. This function is called about 15 times per complete dataset.
function [somevalues] = anotherfunction(somevalues)
.
.
.
After some processing the figures are initialized:
if(Plot)
if(FirstCall)
fh67 = figure(67);
clf(fh67,'reset');
set(fh67,'Position',[579 580 338 370]);
set(fh67,'Name','Filtered ...');
fh68 = figure(68);
clf(fh68,'reset');
set(fh68,'Position',[929 580 338 370]);
set(fh68,'Name','Correlation ...');
fh69 = figure(69);
clf(fh69,'reset');
set(fh69,'Position',[831 130 436 370]);
set(fh69,'Name','Average ...');
The figure handles are saved in somevalues.
end
end
.
.
.
.
After some processing the first figure of three is called:
if(Plot)
%
figure(somevalues.figurehandles.fh69);
stairs(mean_....);grid on
hold on
stairs(sum_...,'b');grid on
xlabel('aaaa')
ylabel('bbb')
title('average ...')
legend('aaa','bbb','Location','SouthEast','Location','NorthEast')
drawnow
hold off
end
.
.
.
.
end