Effacer les filtres
Effacer les filtres

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

44 vues (au cours des 30 derniers jours)
Rami
Rami le 29 Avr 2019
Commenté : Rami le 29 Avr 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?

Réponse acceptée

Jan
Jan le 29 Avr 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 commentaire
Rami
Rami le 29 Avr 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by