How to write a loop that does not increase by +1?
Afficher commentaires plus anciens
Hello :) I currently need to run a loop with the output of "find(collated(1,:) ==0 )". Currently, the output is [2 ; 4 ; 5 ; 6 ; 8], and I need to run the loop with these indexes. I couldn't use a for loop as the number are not increasing by 1. Is there a way I could manage the loop so that the output does not have to run in an +1 order? I read that a while loop may be useful, but am still new to the while loop.
PS
the matrix 'collated' is a 35 x 9 logical, so the idea that I want the code to work is that with each row of collated, I find the 0s i.e in row 1, it will be [2 ; 4 ; 5 ; 6 ; 8], row 2 [2 ;3], row 3 [4; 7; 8; 9] etc...
Appreciate any sort of help! :)
for k = 1:35
while A == find(collated(k,:) ==0)
selectedlocal = find(sesslocal == A);
pfc = dataset_p(1,:);
fef = dataset_f(1,:);
zpfc = zscore(pfc);
zfef = zscore(fef);
zzpfc = zpfc(selectedlocal);
zzfef = zfef(selectedlocal);
[R,P] = corrcoef(zzpfc,zzfef)
end
end
3 commentaires
madhan ravi
le 22 Fév 2020
You haven’t shared the missing datas and your expected result. This would delay the possibility of giving a perfect answer.
David Goodmanson
le 22 Fév 2020
Hi charms, you can do
for k = 2:2:8
(do stuff that depends on k)
end
since the middle 2 sets the increment value
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differentiation 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!