Vectorizing issue in MATLAB

조회 수: 3 (최근 30일)
Hossein Malekahmadi
Hossein Malekahmadi 2021년 1월 21일
편집: Bruno Luong 2021년 1월 21일
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.

채택된 답변

Bruno Luong
Bruno Luong 2021년 1월 21일
It is in general not possible to vectorize sequential calculation like yours.
  댓글 수: 2
Hossein Malekahmadi
Hossein Malekahmadi 2021년 1월 21일
i wrote a code that there is lots of sequential fuction in it.
and when i show it to some one, he told me you use lots of "for" it increase your running time. btw thanks for your time sir.
Bruno Luong
Bruno Luong 2021년 1월 21일
편집: Bruno Luong 2021년 1월 21일
"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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by