For loop execution problem in matlab
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi everyone, i want to do this, like for i=1:10, this function changes 0 to 1 on every first 10 loop iteration which is working in this program, but when the 11 iteration executes then the first 1 in the array changes back to 0 and when the 20th iteration executes i again get all the values equal to 0. Thank you.
clear all;
clc;
A = zeros(1,10);
for i = 1:20
if i<=length(A)
A(i) = 1;
elseif i>length(A) %%%this statement doesn't work
A(i) = 0;
end
end
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 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!