Problem executing while loop

1 回表示 (過去 30 日間)
Olivia Booth-Howe
Olivia Booth-Howe 2019 年 6 月 19 日
Hi everyone,
Thanks in advance for your help.
I am having trouble getting a while loop to work. I am trying to make 20 plots, but only the first plot is made and nothing else.
Additionally, I use the exact same while loop/FileCounter code in a separate script and it works fine to make 20 plots. When I add in the snippet to plot below to the working code, an error comes up about a completely random section of code and even if I delete the new code the error still shows up and I have to close matlab in order to run the original, working code. But may be beside the point.
data_AM = ('<path>');
data_PM = ('<path>');
DataFilesAM=dir(fullfile(data_AM,['*' '.cdf']));
DataFilesPM=dir(fullfile(data_PM,['*' '.cdf']));
FileCounter=1;
while (FileCounter<=20)
%Read in all files/give variable names
t=temp_AM;
td=dp_AM;
for i=1:length(height_AM)
t(i)=temp_AM(i)+273;
td(i)=dp_AM(i)+273;
es(i)=6.11*exp((2.5*10^6/461)*((1/273.15)-(1./t(i))));
ws(i)=(0.622/pres_AM(i))*es(i);
w(i)=(rh_AM(i)/100).*ws(i);
end;
figure(FileCounter)
h=(height_AM);
plot(w*1000, h)
set(gca,'YLim',[30.5 4000]);
FileCounter=FileCounter +1;
end
Any suggestions? I appreciate the help!

回答 (0 件)

カテゴリ

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