Azzera filtri
Azzera filtri

Print matrices whose name is based on loop values

1 visualizzazione (ultimi 30 giorni)
for i = 1:3
eval(['k' num2str(i) '=i']);
end
%% Doubt - How to print k1, k2, k3 based on iteration no. ???

Risposta accettata

Steven Lord
Steven Lord il 21 Lug 2022
Can you dynamically create variables with numbered names like k1, k2, k3, etc.? Yes.
Should you do this? The general consensus is no. That Answers post explains why this is generally discouraged and offers several alternative approaches.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by