フィルターのクリア

How to superimpose multiple images ?

1 回表示 (過去 30 日間)
Jasnoor Singh
Jasnoor Singh 2016 年 6 月 22 日
コメント済み: Walter Roberson 2016 年 6 月 22 日
I have got the following code which generates a number of images. I want to superimpose all the images that are generated from the loop. Can someone please help?
% 2D Plot Code
x = 1:44;
y = 1:44;
set(0,'defaultFigureVisible','off')
for i = 1:10
a = xlsread('JREF P1 air.xlsx',strcat('CO',int2str(46*i+3),':','EF',int2str(46*i+3)));
[xData, yData] = prepareCurveData( x, a );
ft = 'poly9';
[fitresult, gof] = fit( xData, yData, ft, 'Normalize', 'on' );
figure;
h = plot( fitresult,'m' );
title('Air Injection Pressure');
xlabel('X-Direction','FontSize',10);
ylabel('Pressure (kPa)','FontSize',10);
grid on;
axis([1 44 -5 60]);
set(gca,'TickDir','out');
grid off;
view(0,90);
fname = sprintf('2D %d.png',i);
fullFileName = fullfile('\\2D Plots',fname);
saveas(gcf,fullFileName);
end

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 6 月 22 日
編集済み: Walter Roberson 2016 年 6 月 22 日
I would suggest that it would be easier to save the fitting results and plot them all in one plot.
Inside your loop,
savedfits{i} = fitresult;
Then after your loop,
for i = 1 : 10
plot(savedfits{i});
L{i} = sprintf('file #%d', i);
hold on
end
legend(L);
title('Air Injection Pressure');
xlabel('X-Direction','FontSize',10);
ylabel('Pressure (kPa)','FontSize',10);
grid on;
axis([1 44 -5 60]);
set(gca,'TickDir','out');
grid off;
view(0,90);
  2 件のコメント
Jasnoor Singh
Jasnoor Singh 2016 年 6 月 22 日
Hi Walter,
I tried to use this but it gives the following error:
Error using legend>process_inputs (line 503) Cell array argument must be a cell array of strings.
Error in legend>make_legend (line 296) [orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); %#ok
Error in legend (line 250) [h,msg] = make_legend(ha,args(arg:end),version);
Walter Roberson
Walter Roberson 2016 年 6 月 22 日
Please show what you are passing in to legend() and how you are constructing it.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by