How to apply for loop index on plotting?

I have plotted three figures (as shown) with the following program using two for loops, each having two curves blue and red defined by index i and j. The curves in Fig.1 and Fig.2 are exactly the required results of my program, however Fig.3 has only one curve. My question in the program is related to the red encircled syntaxes as shown in the fiugre below. I want to run the syntax: depr(i,:)=(dep(1,:)./dep(2,:)); twice according to the loop index j, so that I obtain two curves in Fig.3.
z=2860:11:3135;
FOV=[1 2];
n=2;
col=['r' 'b'];
[m,~]=size(n);
lineHandles = gobjects(1,m); %ADD THIS
for i=1:length(FOV)
for j=1:n
figure(i);
hold on
I0= getsignal([num2str(j),'FOV_',num2str(FOV(i)),'mrad\out_resultsG_I0.dat']);
Q0= getsignal([num2str(j),'FOV_',num2str(FOV(i)),'mrad\out_resultsG_Q0.dat']);
I(i,:)= smooth(sum(I0,2));
Q(i,:)= smooth(sum(Q0,2));
dep(i,:)= (I(i,:)-Q(i,:))./(I(i,:)+Q(i,:));
plot(dep(i,:),z,'LineWidth',1.5,'color',col(j))
title('\fontname{Arial}Inhomogeneous clouds','Fontsize',12);
%lgd_str={'FOV_{in}','FOV_{out}'};
%legend(lgd_str{i},'location','Southeast');
legend('CM1','CM2','location','Southeast');
FOVs={'Depolarization ratio \delta_{in}','Depolarization ratio \delta_{out}'};
xlabel(FOVs{i});
ylabel('\fontname{Arial}Cloud depth (m)');
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','Fontname','Arial','Fontsmoothing','on');
set(gca,'xlim',[0 1.4],'xtick',[0:0.2:1.4],'ylim',[2850 3150],'ytick',[2850:60:3150]);
set(gca,'xgrid','on','ygrid','on','gridcolor','k');
end
end
for i=1:length(FOV)
for j=1:n
figure (3),
hold on
depr(i,:)=(dep(1,:)./dep(2,:));
plot(depr(i,:),z,'LineWidth',1.5,'color',col(j));
title('\fontname{Arial}Inhomogeneous clouds','Fontsize',12);
%legend('\delta_{in}/\delta_{out}','location','Southeast');
legend('CM1','CM2','location','Southeast');
xlabel('Depolarization ratio \delta_{rat}');
ylabel('\fontname{Arial}Cloud depth (m)');
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','Fontname','Arial','Fontsmoothing','on');
set(gca,'xlim',[0 1.6],'xtick',[0:0.2:1.6],'ylim',[2850 3150],'ytick',[2850:60:3150]);
set(gca,'xgrid','on','ygrid','on','gridcolor','k')
end
end

Answers (1)

Everything here seems fine, just make sure that the second plot in figure 3 falls within the set limits for the axes. It seems like your second plot falls beyond the axes limits set. If that doesn't solve your issue, please share the data or atleast a sample of it.

Categories

Asked:

on 24 May 2021

Answered:

on 27 May 2021

Community Treasure Hunt

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

Start Hunting!