How do I avoid using for loop and vectorize when the i+1 th element of the array depends on the ith
이전 댓글 표시
I want to do the following without the for loop
x=zeros(size(RB_all_m,1),1);
y=zeros(size(RB_all_m,1),1);
index_1=zeros(size(RB_all_m,1),1);
x=sum(indices(1:690,:).*RB_all_m(2:691,:),2);
y=sum(indices(1:691,:).*RB_all_m(1:691,:),2);
for i=1:(size(RB_all_m,1)-1),
index_1(i+1) = index_1(i)*x(i)./y(i);
end
답변 (1개)
카테고리
도움말 센터 및 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!