How do I save the output from a for loop to an array?
Mostrar comentarios más antiguos
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
Respuestas (1)
Voss
el 22 de Jun. de 2022
d = zeros(a,1);
for c = 1:a
d(c) = input(['Enter the number of lines in loop ', num2str(c),': ']);
end
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!