How do I print the following for loop as A1, A2, A3, A4?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kartik Bharadwaj
il 30 Ago 2017
Commentato: Stephen23
il 30 Ago 2017
for i = 1:4
print A%d, i
end
0 Commenti
Risposta accettata
Star Strider
il 30 Ago 2017
Use fprintf or sprintf.
Try this:
for i = 1:4
fprintf('A%d\n', i)
end
0 Commenti
Più risposte (2)
Walter Roberson
il 30 Ago 2017
Modificato: Walter Roberson
il 30 Ago 2017
cellstr( num2str( (1:4).', 'A%d') )
If you have R2017a or later, then consider
"A" + (1:4).'
If you have R2016b, then consider
string('A') + (1:4).'
0 Commenti
Vedere anche
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!