Write cell array to excel format with xlswrite
13 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a cell array AllCoverage containing 4 cell arrays each containing 3 columns and I want to write this out to an excel file.
I tried the following code:
xlswrite('AllCoverage.xls',{'WO_1','WO_2','BL_1','BL_2'};AllCoverage{1},AllCoverage{2},AllCoverage{3},AllCoverage{4});
But i'm getting the following error:
Error: File: Volumes.m Line: 13 Column: 57
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters.
采纳的回答
Thiago Henrique Gomes Lobato
2020-4-5
You need to check the syntax of xlswrite, then you see that you're calling it with wrong arguments. You have to transform your array in one single cell structure and pass it only that structure to the function. The use of ";" is also wrong, every time you use it you tell matlab that the line/command is over, so using it give you this error. I'm not entirerly sure how you want your data, but an example that could work based in your description is this one:
CellTosave = cell(2,12);
CellTosave{1,1} = 'WO_1';
CellTosave{1,4} = 'WO_2';
CellTosave{1,7} = 'BL_1';
CellTosave{1,10} = 'BL_2';
CellTosave{2,1} = AllCoverage{1};
CellTosave{2,4} = AllCoverage{2};
CellTosave{2,7} = AllCoverage{3};
CellTosave{2,10} = AllCoverage{4};
xlswrite('AllCoverage.xls',CellTosave);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!