Issues in For loop
이전 댓글 표시
Hi All,
I ma facing issues while reading data and saving in to desired fashion. Here is an example, I need to save the temperature and salinity from a large dataset in every 120th raw for which i wrote the code as shown below.....is there any error? as I am recieving the entire data filed instead of every 120th one....
for i=1:38976;
if(j==120);
if(temp(i)> 0 && temp(i) < 30 );
temp(i)=temp(i) ;
else
temp(i)=NaN;
end
if(sal(i)> 30 && sal(i)< 42);
sal(i)=sal(i);
else
sal(i)=NaN;
end
j=1;
else
j=j+1;
end
end
채택된 답변
추가 답변 (1개)
Alan Stevens
2021년 6월 23일
0 개 추천
Have you intialised j (i.e. set j = 1;) before going into the for i = 1:38976 loop?
카테고리
도움말 센터 및 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!