Hi,
I have a cell array 'a' with k rows and 5 columns and i want to write this in a text file with the same structure. Each row is for example: a={'France' 'TV-Y7' 'Australia' 'G' 1}.
I open the file with the commant: 'fid=fopen('results.txt', 'at+');' and then i try fwrite and fprintf but it doesn't work..
Can anybody help me with this?
|
|
0
|
|
|
|
Reply
|
maria
|
10/4/2010 4:14:19 PM |
|
> I have a cell array 'a' with k rows and 5 columns and i want to write this
> in a text file with the same structure. Each row is for example:
> a={'France' 'TV-Y7' 'Australia' 'G' 1}.
> I open the file with the commant: 'fid=fopen('results.txt', 'at+');' and
> then i try fwrite and fprintf but it doesn't work..
> Can anybody help me with this?
Your case looks similar to the example here:
http://www.mathworks.com/help/techdoc/import_export/f5-15544.html#br2ypq2-1
Sample code:
fid = fopen('results.txt', 'w');
for row=1:k
fprintf(fid, '%s %s %s %s %d\n', a{row,:});
end
fclose(fid);
|
|
0
|
|
|
|
Reply
|
Leslie_McBrayer
|
10/4/2010 4:50:26 PM
|
|