how to make a text file contanining a dilimited(comma) matrix and not the same sig figs per column
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
%say I have this matrix:
C=[4,10;5,20;6,30;7,40]
%and I want to develop a txt file such that it contains
4, 10
5, 20
6, 30
7, 40
%the dlmwrite function doesn't let me keep the matrix as it exactly looked but rather ask me to decide on the same # of sig figs for all columns such as:
dlmwrite('mytext.txt', C, 'precision', '%.2f','newline', 'pc');
4.00, 10,00
5.00, 20.00
6.00, 30.00
7.00, 40.00
anyone can help how I can make the txt file look like the following and not how dlmwrite does it:
4, 10
5, 20
6, 30
7, 40
Antworten (2)
Fangjun Jiang
am 29 Jul. 2011
0 Stimmen
try %d instead of %.2f
Bruno
am 29 Jul. 2011
0 Stimmen
2 Kommentare
Fangjun Jiang
am 29 Jul. 2011
type doc sprintf to see all other format, such as %g, %G. You should be able to find what you want.
Walter Roberson
am 29 Jul. 2011
%g is probably the way to go.
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!