How do I save the output from a for loop to an array?
이전 댓글 표시
clc;
clear;
%user enters the number of loops
a=input('Enter the number of loops in the system: ');
b=(1:a);
i=transpose(b);
%user enters the number of lines in each loop
%How do I get the the outputs from the for loop to be saved to an array that I can call later in the program?
for c=1:a;
d=input(['Enter the number if lines in loop ', num2str(c),': ']);
end
답변 (1개)
Voss
2022년 6월 22일
d = zeros(a,1);
for c = 1:a
d(c) = input(['Enter the number of lines in loop ', num2str(c),': ']);
end
카테고리
도움말 센터 및 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!