New variables in a loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone! I'm facing some issues while trying to create new variables inside a loop. Can I load my data using a for loop while keeping first character (m)?
Thanks in advance!
0 commentaires
Réponses (1)
KALYAN ACHARJYA
le 25 Déc 2019
Modifié(e) : KALYAN ACHARJYA
le 25 Déc 2019
Considering the array or cell array is best way rather than assigning new variable in each iteration.
Fs=zeros(1,35);
for i=1:35
Fs(i)=L(i)/tmax(i); % assuming L and tmax both are scalars
end
% Assuming L and tmax both are scalars, if not then
Fs=cell(1,35);
for i=1:35
Fs{i}=L(i)/tmax(i);
end
2 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!