Saving cell array data from uitable using 'save'
조회 수: 8 (최근 30일)
이전 댓글 표시
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
채택된 답변
Geoff Hayes
2016년 6월 4일
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
Geoff Hayes
2016년 6월 6일
I wondered about that. When I tried, I didn't need the text specifier. (R2014a, Mac OS)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!