Write cell array to excel format with xlswrite

12 次查看(过去 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
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 个)

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by