How do I print the following for loop as A1, A2, A3, A4?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kartik Bharadwaj
am 30 Aug. 2017
Kommentiert: Stephen23
am 30 Aug. 2017
for i = 1:4
print A%d, i
end
0 Kommentare
Akzeptierte Antwort
Star Strider
am 30 Aug. 2017
Use fprintf or sprintf.
Try this:
for i = 1:4
fprintf('A%d\n', i)
end
0 Kommentare
Weitere Antworten (2)
Walter Roberson
am 30 Aug. 2017
Bearbeitet: Walter Roberson
am 30 Aug. 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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!