how to use fprintf to print strings and words
38 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nabil Abdullah
am 15 Mär. 2017
Kommentiert: Nabil Abdullah
am 15 Mär. 2017
Dear All,
I would like to ask how I would get fprintf to produce the following where A = [{'a'} {'b'} {'c'}], B = [1 2 3],
>> a 1
b 2
c 3
Thank you
0 Kommentare
Akzeptierte Antwort
Jan
am 15 Mär. 2017
A = {'a', 'b','c'}; % A nicer notation
B = [1 2 3];
Either a loop:
for k = 1:length(A)
fprintf('%s %g\n', A{k}, B(k));
end
Or create one cell at first:
C = cat(1, A, num2cell(B));
fprintf('%s %g\n', C{:});
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!