Vectorizing issue in MATLAB
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hossein Malekahmadi
am 21 Jan. 2021
Bearbeitet: Bruno Luong
am 21 Jan. 2021
Hi I have problem with vectorizing in MATLAB that im not even sure there is possible way to do it, i glad if you can check it as well.
a(1)=1000;
for i=1:20
a(i+1)=sqrt((a(i)+1));
end
Is there any way to vectorizing it or i should use "for" when i want use this type of functions?
i tried search for answer, i didnt find any, i hope some one can answer me thanks.
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 21 Jan. 2021
It is in general not possible to vectorize sequential calculation like yours.
2 Kommentare
Bruno Luong
am 21 Jan. 2021
Bearbeitet: Bruno Luong
am 21 Jan. 2021
"he told me you use lots of "for" it increase your running time"
You are miss informed by this person.
It all depends what you do inside the for-loop. Yours look OK to me.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!