Problem with writing a matrix into a text file
Ältere Kommentare anzeigen
Hi!
I did a script for making a 100x100 matrix and tried to convert it into a text file. The code goes lie this:
a=zeros(100,100);
for i=1:100
for j=1:100
a(j,i)=30;
end
end
dlmwrite('grid.txt', a, 'delimiter', '\t')
type grid.txt
The first couple of lines of the text come out okay, but then there are some elements like 3030 or 3 and at the end of the lines some elements are empty or zeros. Also the matrix does not look like 100x100 in the text file, more like 333x30. What is the problem in this?
Thanks
Antworten (1)
per isakson
am 11 Okt. 2012
Bearbeitet: per isakson
am 11 Okt. 2012
0 Stimmen
I run your code on R2012a, 64Bit, Win7. It works as expected. I see neither 3 nor 3030.
- Open in Excel produced a 100 row sheet. Last column is CV.
- Open in Matlab editor it looks ok
- Import data to Matlab gives a <100x100 double > array
- type grid.txt gives the expected result in the command window
Did you try to change your tab settings of the editor?
Kategorien
Mehr zu Text Files finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!