Saving cell array data from uitable using 'save'
1 view (last 30 days)
Show older comments
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');
0 Comments
Accepted Answer
Geoff Hayes
on 4 Jun 2016
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!
3 Comments
Geoff Hayes
on 6 Jun 2016
I wondered about that. When I tried, I didn't need the text specifier. (R2014a, Mac OS)
More Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!