Save an output file which is a cell

1 回表示 (過去 30 日間)
Lavanya S
Lavanya S 2018 年 10 月 11 日
回答済み: OCDER 2018 年 10 月 11 日
How to write a cell to excel sheet (or in any format). The cell contains strings as well as doubles. Thanks in advance

回答 (1 件)

OCDER
OCDER 2018 年 10 月 11 日
Data = {'string', 1, [1 2 3 4]};
%Make sure there is no multi-element entity in each cell (like the matrix)
MatLoc = cellfun(@(x) isnumeric(x) && numel(x) > 1, Data);
Data(MatLoc) = cellfun(@mat2str, Data(MatLoc), 'un', 0);
xlswrite('MyFile.xlsx', Data);
%OR
writetable(cell2table(Data), 'MyFile2.xlsx'); %Use (..., 'WriteVariableNames', 0) inputs if
%you don't want "Data1, Data2, Data3" as the first row

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by