Effacer les filtres
Effacer les filtres

Write cell array to excel format with xlswrite

23 vues (au cours des 30 derniers jours)
Wout Depoot
Wout Depoot le 5 Avr 2020
Commenté : Wout Depoot le 5 Avr 2020
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.

Réponse acceptée

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);
  1 commentaire
Wout Depoot
Wout Depoot le 5 Avr 2020
Thanks, this worked just fine!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by