How do I save the output from a for loop to an array?
Afficher commentaires plus anciens
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
Réponses (1)
Voss
le 22 Juin 2022
d = zeros(a,1);
for c = 1:a
d(c) = input(['Enter the number of lines in loop ', num2str(c),': ']);
end
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!