MATLAB: Saving cell array data from uitable using ‘save’

cellarraysaveuitable

I have the data from a uitable as:
inputdata =
'300' [101.0366] [0.7744] [0.3806]
'600' [101.2867] [0.4358] [0.1959]
'1000' [101.2317] [0.4522] [0.1898]
'2000' [101.4917] [0.5007] [0.2892]
'4000' [101.6842] [0.6338] [0.4064]
I am trying to save to a text file, but the following doesn't work.
inputdata=(get(handles.uitableDark,'Data'))
save('C\:DarkFPN.txt','inputdata','-ascii');

Best Answer

Jason - since inputdata is a cell array, I suspect that you are observing the following error
Warning: Attempt to write an unsupported data type to an ASCII file.
Variable 'inputdata' not written to file.
Is this is true, what can you tell us about your data from the uitable. Your example has a mix of numeric datatype and character arrays (the first column). Can you convert this first column to doubles and so have a matrix all of the same data type? If so, then you will be able to use the above save function.
If not, then I would use the example from export cell array to text file which uses fprintf to write the data to file. Something like
fid = fopen('myData.txt','w');
if fid > 0
[nrows,ncols] = size(inputdata);
for row = 1:nrows
fprintf(fid,'%s %f %f %f\n',inputdata{row,:});
end
fclose(fid);
end
Try the above and see what happens!