Issues in For loop
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Alan Stevens
le 23 Juin 2021
0 votes
Have you intialised j (i.e. set j = 1;) before going into the for i = 1:38976 loop?
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!