필터 지우기
필터 지우기

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 CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by