From: CyberFrog on
Hi,
I have a cell array full of data so that when I type this array name in the matlab terminal you get:

K>> my_data

my_data =

Columns 1 through 7

[17x1 char] [17x1 char] [18x1 char] [18x1 char] [18x1 char] [18x1 char] [17x1 char]
[17x1 char] [17x1 char] [18x1 char] [18x1 char] [18x1 char] [18x1 char] [17x1 char]
[17x1 char] [17x1 char] [18x1 char] [18x1 char] [18x1 char] [18x1 char] [17x1 char]
[17x1 char] [17x1 char] [18x1 char] [18x1 char] [18x1 char] [18x1 char] [17x1 char]


as you would expect. Now the size of this cell array is 300 x 300 i.e. 300 rows by 300 columns

What is the best way to code this to print this to a file?

I ihave tried a loop so far but its proving quite difficult to get it printing onto a new line as I print all the columns for each row first.

my code so far is:
[len_rows,len_cols]=size(my_data);
for num_cols=1:len_cols


for num_rows=1:len_rows
if num_rows==len_rows
fprintf(fid,'\n');
end

fprintf(fid,'%s\t',my_data{num_rows,len_cols}');
end

end
 | 
Pages: 1
Prev: dialysis project using simscape
Next: contour plot