I have obtained 17 figures from the program below but each figure is displayed seperately. I want to merge them all and plot them as only one figure.
EC = [0.0052 0.0078 0.0104 0.013 0.0156 0.0182];
Reff = 4:1:20;
h=2115:9:2394;
for j = 1:length(Reff)
figure,
hold on
for i = 1:length(EC)
filename1 = [num2str(EC(i)),'\',num2str(Reff(j)),'um\out_resultsG_I0.dat'];
I1 = getsignal(filename1);
I1(isnan(I1))=0;
I0_1 = sum(I1,2);
filename1 = [num2str(EC(i)),'\',num2str(Reff(j)),'um\out_resultsG_Q0.dat'];
Q1 = getsignal(filename1);
Q1(isnan(Q1))=0;
Q0_1 = sum(Q1,2);
dep=(I0_1-Q0_1)./(I0_1+Q0_1);
plot(dep,h,'LineWidth',2);
title(['Effective radius=',num2str(Reff(j)),'\mum',', FOV=2mrad'],'FontSize',12,'FontWeight','normal');
xlabel('Depolarisation ratio \delta_{out}','FontSize',12,'FontWeight','normal');
ylabel('Cloud depth (m)','FontSize',12,'FontWeight','normal');
end
legend(['EC=',num2str(EC(1)),'/m'],['EC=',num2str(EC(2)),'/m'],['EC=',num2str(EC(3)),'/m'],...
['EC=',num2str(EC(4)),'/m'],['EC=',num2str(EC(5)),'/m'],['EC=',num2str(EC(6)),'/m'],'location','Southeast')
end

2 commentaires

Rik
Rik le 29 Jan 2021
You're the one who put figure inside the for-loop. You only need to modify what you put in your legend, but otherwise removing that call should be your solution. Or do you want something different?
Wiqas Ahmad
Wiqas Ahmad le 29 Jan 2021
Simply say that I have plotted the six curves in the front figure 17 times, but each time they are displayed on a seperate figure. I wan to plot all these curves17times on a single figure.

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 29 Jan 2021
I wan to plot all these curves17times on a single figure.
Put the figure call before the loops:
figure
hold on
for j = 1:length(Reff)
for i = 1:length(EC)
... etc. ...
and:
hold off
after the loops, so you do not plot anything else to those axes later in your code.

4 commentaires

Wiqas Ahmad
Wiqas Ahmad le 30 Jan 2021
It works well but didn't solve my problem. Actually I want to apply the first loop index "j" on the statment "dep=(I0_1-Q0_1)./(I0_1+Q0_1);" so that "dep" runs 17 times. Now the output "dep" is 32*1 dubble form as shown in figure. I want to get "dep" in the form of 32*17 dubble form
Small problem:
Unrecognized function or variable 'getsignal'.
I1 = getsignal(filename1);
so I defer to you to experiment with this.
Try this:
EC = [0.0052 0.0078 0.0104 0.013 0.0156 0.0182];
Reff = 4:1:20;
h=2115:9:2394;
for j = 1:length(Reff)
for i = 1:length(EC)
filename1 = [num2str(EC(i)),'\',num2str(Reff(j)),'um\out_resultsG_I0.dat'];
I1 = getsignal(filename1);
I1(isnan(I1))=0;
I0_1 = sum(I1,2);
filename1 = [num2str(EC(i)),'\',num2str(Reff(j)),'um\out_resultsG_Q0.dat'];
Q1 = getsignal(filename1);
Q1(isnan(Q1))=0;
Q0_1 = sum(Q1,2);
dep(i,j)=(I0_1-Q0_1)./(I0_1+Q0_1);
end
end
figure
plot(dep,h,'LineWidth',2);
title(['Effective radius=',num2str(Reff(j)),'\mum',', FOV=2mrad'],'FontSize',12,'FontWeight','normal');
xlabel('Depolarisation ratio \delta_{out}','FontSize',12,'FontWeight','normal');
ylabel('Cloud depth (m)','FontSize',12,'FontWeight','normal');
legend(['EC=',num2str(EC(1)),'/m'],['EC=',num2str(EC(2)),'/m'],['EC=',num2str(EC(3)),'/m'],...
['EC=',num2str(EC(4)),'/m'],['EC=',num2str(EC(5)),'/m'],['EC=',num2str(EC(6)),'/m'],'location','Southeast')
It may be necessary to reverse the ‘(i,j)’ reference, however if you want to plot it against ‘h’ that should not be a problem with the plot. It would only be a problem if the components of ‘dep’ require that those indices be reversed.
.
Wiqas Ahmad
Wiqas Ahmad le 31 Jan 2021
Thank you. This is what I was required
Star Strider
Star Strider le 31 Jan 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by