MATLAB: How to include text and variable in excel sheet name when using xlswrite

include variable and text in excel sheet namexlswrite give excel sheet name of variable and text

Hello, Is it possible to include variable and text in excel sheet name when we writing the result to that excel sheet using xlswrite command.
I know how to include variable only by using num2str(variable(j)).
I have tried ['Classic: ', num2str(variable(j)),'deg']but error message says :
Error using xlswrite (line 219)
The specified data range is invalid or too large to write to the specified file format. Try writing to an XLSX file and use Excel A1 notation for the range argument, for example, A1:D4.
Appreciate any suggestion Aziz

Best Answer

Yes, use sprintf() to create a sheet name from your variables:
sheetName = sprintf('%s %d', yourString, yourInteger);
cellRef = 'D3'; % Whatever
xlswrite(filename, yourData, sheetName, cellRef);