Filter löschen
Filter löschen

How to writematrix with a different sheet name in a for loop matlab

44 Ansichten (letzte 30 Tage)
Rami
Rami am 29 Apr. 2019
Kommentiert: Rami am 29 Apr. 2019
I have the following vector of arrays
AzizSheetName ={'Joint Angle R.Ankle.X', 'Joint Angle R.Ankle.Y', 'Joint Angle R.hip.X', 'Joint Angle R.hip.Y', 'Joint Moment R.Ankle.X', 'Joint Moment R.Ankle.Y', 'Joint Moment R.hip.X', 'Joint Moment R.hip.Y'};
and there shall be the names of the sheets of a xlsx file that I would like to create
for j=1:numel(sheet_name)
writematrix(NewData{j},Newfilename,AzizSheetName(j))
end
Obviously this does not work, and this is the one that works
for j=1:numel(sheet_name)
writematrix(NewData{j},Newfilename,'Sheet',j)
end
However, I do not want things to be named sheet 1, sheet 2, ect.
Can someone help me please?

Akzeptierte Antwort

Jan
Jan am 29 Apr. 2019
What about
AzizSheetName ={'Joint Angle R.Ankle.X', 'Joint Angle R.Ankle.Y', 'Joint Angle R.hip.X', 'Joint Angle R.hip.Y', 'Joint Moment R.Ankle.X', 'Joint Moment R.Ankle.Y', 'Joint Moment R.hip.X', 'Joint Moment R.hip.Y'};
for j=1:numel(sheet_name)
writematrix(NewData{j}, Newfilename, 'Sheet', AzizSheetName{j});
% ^^^^^^^ ^ ^ curly braces
end
"Obviously this does not work" - instead of such a general statement, a copy of the complete error message would reveal some details.
  1 Kommentar
Rami
Rami am 29 Apr. 2019
Thank you for that, but it is still creating a 3 empty sheet with sheet1, sheet2, sheet3... How may I get rid of it?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by