# How to apply for loop index on plotting?

2 ビュー (過去 30 日間)
Wiqas Ahmad 2021 年 5 月 24 日

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);
for i=1:length(FOV)
for j=1:n
figure(i);
hold on
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

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

### 回答 (1 件)

Rishik Ramena 2021 年 5 月 27 日
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.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by