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

excelwritematrixxlswrite

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?

Best Answer

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.