Simple Question about Optimization of a FOR loop
이전 댓글 표시
How can I optimize (vectorize?) the following code in order to avoid the for loop and make the code to run faster?
for i=1:55;
A(i)=B((i-1)*3+1,1);
end
A is 1 x 55 and B is 165 x 1
Many thanks!
댓글 수: 3
Matt Kindig
2013년 6월 14일
This loop will make A only 1x55, not 55x55.
Laila Kazemi
2013년 6월 14일
bc ur only assigning one raw to A
Mohsen
2013년 6월 14일
답변 (2개)
Laila Kazemi
2013년 6월 14일
0 개 추천
C= B*3 +1 A (1:55, 1:55)= C(1:55, 1)
but the dimensions of ur matrices dont match , if B was 55 by 1 , it would have worked
댓글 수: 3
Laila Kazemi
2013년 6월 14일
C= B*3 +1
A (1:55, 1:55)= C(1:55, 1)
Laila Kazemi
2013년 6월 14일
actaully instead one make a matrix called D with D( , 1:165)=(1)
Mohsen
2013년 6월 16일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!