Vectorizing a for loop?
이전 댓글 표시
How would I rewrite this code using say repmat to vectorize it and get rid of the for loop? I have been playing with this, but cannot figure it out. All I am doing is solving the ss2 equation while increasing ILAT. Thank you
A1=[0 0 0];
B1=[-5 5 0];
npan2=3
for ILAT=1:npan1+1
ss2=A1+(B1-A1)/(npan2)*((ILAT)-1);
mat(ILAT,:)=ss2
end
채택된 답변
추가 답변 (2개)
Christopher
2013년 7월 11일
0 개 추천
Andrei Bobrov
2013년 7월 11일
out = (0:npan1).'*(A1+(B1-A1)/npan2);
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!