Problem executing while loop

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 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by