in a csv file, it is a line like(45,85​,65,98,36,​56,83,10,8​,7),how can i make it 10*1 cell? thanks

the result what i want is:
45
85
65
98
36
83
10
8
7
I try to write like this
fid = fopen('R003.csv', 'wt');
fprintf(fid, '%s\n', R{:});
fclose(fid);
but the result has a small problem the result is like this
45,85,65,98,36,56,83,10,8,7
85
65
98
36
83
10
8
7
can you help me? thanks

 Accepted Answer

If you want to write a .csv file, consider using csvsrite instead of fprintf.
Create it as a column vector, then write it:
V = [45,85,65,98,36,56,83,10,8,7]'; % Note Transpose
csvwrite('R003.csv', V)

4 Comments

I already have a csv file,I want to change its ordre,from a line to a row, it's like 45,85,65,98,36,56,83,10,8,7 but now i want it like 45 85 65 98 36 83 10 8 7 so i use fprintf(fid, '%s\n', R{:}); but il doesn't work very well
I edited my answer to include an example that will write the vector in a column rather than a row. I believe that is what you want.
thank you very much,and i modify that fprintf ,now it can work vell,two methodes are correct
My pleasure!
If it worked for you, I would appreciate it if you would Accept my Answer.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!