csvwrite with a double
6 ビュー (過去 30 日間)
古いコメントを表示
Hello I am having a great deal of difficulty writing a 512 x 1 cell array of type double in a .MAT file to excel I tried this:
exportlist = get(handles.listbox2,'string')
%we need to change the directory to the chosen output and after we have %re-loaded the .mat file into the workspace convert the files %The evalin evaluates the expression in 'base' or workspace
for a = 1:length(exportlist) outloc =get(handles.CSV_file, 'string'); cdstring = ['cd(''' outloc ''')']; eval(cdstring); csvwrite([exportlist{a},'.csv'],evalin('base',cell2mat(exportlist{a})))
end
No dice. The error I get is this:
??? Cell contents reference from a non-cell array object.
Error in ==> cell2mat at 44 cellclass = class(c{1});
Error in ==> MAT_to_Csv>convert_button_Callback at 319 csvwrite([exportlist{a},'.csv'],evalin('base',cell2mat(exportlist{a})))
Thanks
Bill
0 件のコメント
採用された回答
Fangjun Jiang
2011 年 6 月 17 日
No. Your line probably should be:
csvwrite([exportlist{a},'.csv'],evalin('base',exportlist{a}))
Read my answer to your other question. I think you should really consider the dynamic field names like Vars.(exportlist{a}) to avoid using eval().
Your eval(cdstring) could be replaced by cd(outloc)
1 件のコメント
Walter Roberson
2011 年 6 月 18 日
Yes, yes, dynamic field names! And pass the structure in as a parameter or work with in via handles, so that you do not need to use evalin()
その他の回答 (1 件)
Walter Roberson
2011 年 6 月 18 日
I would also add the precautionary measure of using
exportlist = cellstr(get(handles.listbox2,'string'));
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!