Why I cannot get accurate curves using for loops?

1 view (last 30 days)
Wiqas Ahmad
Wiqas Ahmad on 7 Sep 2021
Answered: Star Strider on 7 Sep 2021
close all;
clear all;
clc;
%% ------------------------------Program-------------------------------------
z=2100:7.5:2242.5;
FOV=[1];
EC=[0.0078 0.015 0.024 0.036];%/m
Reff =[4 8 13 18];
for i = 1:length(EC)
for j = 1:length(Reff)
ILP= getsignal([num2str(EC(i)),'\','1100','\',num2str(Reff(j)),'um\out_resultsG_I0.dat']);
QLP= getsignal([num2str(EC(i)),'\','1100','\',num2str(Reff(j)),'um\out_resultsG_Q0.dat']);
I1(:,j)= smooth(sum(ILP(:,j),2));
Q1(:,j)= smooth(sum(QLP(:,j),2));
Iv= getsignal([num2str(EC(i)),'\','1-100','\',num2str(Reff(j)),'um\out_resultsG_I0.dat']);
Qv= getsignal([num2str(EC(i)),'\','1-100','\',num2str(Reff(j)),'um\out_resultsG_Q0.dat']);
I2(:,j)= smooth(sum(Iv(:,j),2));
Q2(:,j)= smooth(sum(Qv(:,j),2));
ICP= getsignal([num2str(EC(i)),'\','1001','\',num2str(Reff(j)),'um\out_resultsG_I0.dat']);
VCP= getsignal([num2str(EC(i)),'\','1001','\',num2str(Reff(j)),'um\out_resultsG_V0.dat']);
I3(:,j)= smooth(sum(ICP(:,j),2));
V3(:,j)= smooth(sum(VCP(:,j),2));
Ilc= getsignal([num2str(EC(i)),'\','100-1','\',num2str(Reff(j)),'um\out_resultsG_I0.dat']);
Vlc= getsignal([num2str(EC(i)),'\','100-1','\',num2str(Reff(j)),'um\out_resultsG_V0.dat']);
I4(:,j)= smooth(sum(Ilc(:,j),2));
V4(:,j)= smooth(sum(Vlc(:,j),2));
end
end
for i = 0.0078
for j = 1:length(Reff)
dep1(:,j)= (I1(:,j)-Q1(:,j))./(I1(:,j)+Q1(:,j));%Linearly parallely polarized
end
end
for i = 0.015
for j = 1:length(Reff)
dep2(:,j)= (I2(:,j)+Q2(:,j))./(I2(:,j)-Q2(:,j)); %Linearly perpendicularly polarized
end
end
for i = 0.024
for j = 1:length(Reff)
dep3(:,j)= (I3(:,j)+V3(:,j))./(I3(:,j)-V3(:,j)); %Circularly parallely polarized
end
end
for i = 0.036
for j = 1:length(Reff)
dep4(:,j)= (I4(:,j)-V4(:,j))./(I4(:,j)+V4(:,j)); %Circularly perpendicularly polarized
end
end
figure('Name','0.0078')
t = tiledlayout(1,2,'TileSpacing','Compact','Padding','Compact');
%Tile 1
nexttile
hold on
plot(dep1(1,1),z,'b-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(1,2),z,'b-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(1,3),z,'b-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(1,4),z,'b-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(2,1),z,'b-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(2,2),z,'b-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(2,3),z,'b-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(2,3),z,'b-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(3,1),z,'b-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(3,2),z,'b-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(3,3),z,'b-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(3,4),z,'b-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(4,1),z,'b-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(4,2),z,'b-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(4,3),z,'b-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
plot(dep1(4,4),z,'b-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','b','MarkerFaceColor','b');
hold on
plot(dep2(1,1),z,'r-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(1,2),z,'r-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(1,3),z,'r-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(1,4),z,'r-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(2,1),z,'r-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(2,2),z,'r-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(2,3),z,'r-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(2,4),z,'r-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(3,1),z,'r-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(3,2),z,'r-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(3,3),z,'r-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(3,4),z,'r-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(4,1),z,'r-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(4,2),z,'r-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(4,3),z,'r-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
plot(dep2(4,4),z,'r-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','r','MarkerFaceColor','r');
hold on
title('\fontname{Arial}Linear polarization','Fontsize',12);
%leg2=legend(h([1 4]),{'\delta_{lin\mid\mid}','\delta_{lin\perp}'},'location','Northeast','FontSize',12);
%legend off
xlabel('\fontname{Arial}Depolarization ratio \delta_{v}');
ylabel('\fontname{Arial}Cloud depth (m)');
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','boxstyle','full','Fontname','Arial','Fontsmoothing','on');
set(gca,'xlim',[0 0.1],'xtick',[0:0.025:0.1],'ylim',[2100 2250],'ytick',[2100:30:2250]);
set(gca,'xgrid','on','ygrid','on','gridcolor','k');
text(0.025,2235,'C1-cloud model\newline(\gamma=7,m=1.33,\newline\alpha_{ext}=0.0078m^{-1})',...
'Color','black','FontSize',13,'FontWeight','normal','FontName','Arial')
nIDs = 1;
alphabet = ('a':'z').';
chars = num2cell(alphabet(1:nIDs));
chars = chars.';
charlbl = strcat('(',chars,')'); % {'(a)','(b)','(c)','(d)'}
text(0.03,0.96,charlbl{1},'Units','normalized','FontSize',14)
%Tile 2
nexttile
hold on
plot(dep3(1,1),z,'k-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(1,2),z,'k-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(1,3),z,'k-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(1,4),z,'k-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(2,1),z,'k-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(2,2),z,'k-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(2,3),z,'k-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(2,4),z,'k-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(3,1),z,'k-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(3,2),z,'k-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(3,3),z,'k-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(3,4),z,'k-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(4,1),z,'k-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(4,2),z,'k-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(4,3),z,'k-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
plot(dep3(4,4),z,'k-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','k','MarkerFaceColor','k');
hold on
plot(dep4(1,1),z,'g-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(1,2),z,'g-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(1,3),z,'g-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(1,4),z,'g-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(2,1),z,'g-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(2,2),z,'g-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(2,3),z,'g-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(2,4),z,'g-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(3,1),z,'g-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(3,2),z,'g-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(3,3),z,'g-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(3,4),z,'g-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(4,1),z,'g-','LineWidth',1.5,'Marker','o','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(4,2),z,'g-','LineWidth',1.5,'Marker','h','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(4,3),z,'g-','LineWidth',1.5,'Marker','*','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
plot(dep4(4,4),z,'g-','LineWidth',1.5,'Marker','s','MarkerSize',7,'MarkerEdgeColor','g','MarkerFaceColor','g');
hold on
title('\fontname{Arial}Circular polarization','Fontsize',12);
%legend(h([9 13]),{'\delta_{cir\mid\mid}','\delta_{cir\perp}'},'location','west','FontSize',12);
%legend off
xlabel('\fontname{Arial}Depolarization ratio \delta_{v}');
%ylabel('\fontname{Arial}Cloud depth (m)');
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','boxstyle','full','Fontname','Arial','Fontsmoothing','on');
set(gca,'xlim',[0 0.2],'xtick',[0:0.05:0.2],'ylim',[2100 2250],'ytick',[2100:30:2250]);
set(gca,'xgrid','on','ygrid','on','gridcolor','k');
text(0.05,2235,'C1-cloud model\newline(\gamma=7,m=1.33,\newline\alpha_{ext}=0.0078m^{-1})',...
'Color','black','FontSize',13,'FontWeight','normal','FontName','Arial')
nIDs = 2;
alphabet = ('a':'z').';
chars = num2cell(alphabet(1:nIDs));
chars = chars.';
charlbl = strcat('(',chars,')'); % {'(a)','(b)','(c)','(d)'}
text(0.03,0.95,charlbl{2},'Units','normalized','FontSize',14)
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[.3 .3 .65 .6])
Can anybody help me to do some correction to my program? I want to obtain 4 curves (Reff) for each value of EC defined by two indices, i and j. The right side shows the figure when zoom out. The

Answers (1)

Star Strider
Star Strider on 7 Sep 2021
It is not possible for me to run the posted code.
With respect to the plots, perhaps using semilogx would work (instead of plot), providing all the ‘Depolarization Ratio values are >0.
.

Community Treasure Hunt

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

Start Hunting!