mat to xlsx conversion

20 ビュー (過去 30 日間)
Sugar Mummy
Sugar Mummy 2022 年 1 月 4 日
回答済み: laurent jalabert 2022 年 1 月 5 日
Hello everyone! I am trying to convert my .mat file using the following code
data=load('Check.mat');
f=fieldnames(data);
for k=1:size(f,1)
writetable('Check.xlsx',data.(f{k}),f{k})
end
Here I am getting the following error.
Error using writematrix (line 191)
Wrong number of arguments. A filename must be provided when supplying additional parameters, and each parameter name must be followed by a value.
Any help would be highly appreciated. Thanks!
  2 件のコメント
Rik
Rik 2022 年 1 月 4 日
These are the syntax options:
writematrix(A)
writematrix(A,filename)
writematrix(___,Name,Value)
You are using none of the above.
You should have a read in the optional parameters section. This will probably overwrite your data each pass.
Walter Roberson
Walter Roberson 2022 年 1 月 4 日
'sheetname' is probably needed.

サインインしてコメントする。

回答 (1 件)

laurent jalabert
laurent jalabert 2022 年 1 月 5 日
YourArray = [col1;col2;...]; % vectors
varNames_ARR = {'col_1';'col_2';...}; %strings - header of your vector column (do not use space, -, or anything else than _)
Z_MOY_name = 'name';
a=1 ; %sheet number 1
Z_MOY = array2table(YourArray,'VariableNames',varNames_ARR);
writetable(Z_MOY,Z_MOY_name,'Sheet',a); % array, name,'sheet',index

カテゴリ

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