KiW
KiW

Reputation: 593

Csvwrite returns a single line output instead of multiple lines (displayed in notepad)

Aim

I want to write a .csv file in the following format

1253.7500,1295.5000,-403.7500,1,0.000
1253.7500,1295.5000,-401.2500,1,0.000
1258.7500,1294.5000,-403.7500,1,0.000
1258.7500,1294.5000,-401.2500,1,0.000
1257.5000,1295.5000,-402.5000,1,0.000

Code If i use .csvwrite as follows

m = [3 6 9 12 15; 5 10 15 20 25; ...
 7 14 21 28 35; 11 22 33 44 55];
csvwrite('test1.dat',m);
type test1.dat

Matlab displays it correctly like this:

3,6,9,12,15
5,10,15,20,25
7,14,21,28,35
11,22,33,44,55

Problem

I want to import it into another program which would need the above format but if I open the created file in notepad it looks like this:

3,6,9,12,**155**,10,15,20,**257**,14,21,28,**3511**,22,33,44,55

(The stars dont appear I used them to highlight the problem area as here two numbers get combined)

Is there a way to write it in a .csv file without this happening ?

Upvotes: 1

Views: 143

Answers (1)

KiW
KiW

Reputation: 593

The problem actually lies within notepad, not the code or matlab. Using notepad++ it is displayed correctly as:

enter image description here

If used with .csv instead of .dat format

m = [3 6 9 12 15; 5 10 15 20 25; ...
 7 14 21 28 35; 11 22 33 44 55];
csvwrite('test1.csv',m);
type test1.csv

it can be checked in Excel as well and it is shown correctly:

enter image description here

Upvotes: 3

Related Questions