how to write this without loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
hi! i wrote this in matlab:
%
r is a mtrix of the size(25*30000)
for l=1:30000
for k=2:25
d(k,l)=r(k,l)-r(k-1,l);
if d(k,l)<-109
r(k,l)=r(k,l)+300;
elseif d(k,l)>180
r(k,l)=r(k,l)-300;
end
end
end
how could write this with minimal loops?
thank you
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 1 Mär. 2013
You can start with diff(r), and then use logical indexing.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!