필터 지우기
필터 지우기

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

조회 수: 8 (최근 30일)
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

채택된 답변

Image Analyst
Image Analyst 2017년 7월 3일
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);
  댓글 수: 2
Abdulaziz Abutunis
Abdulaziz Abutunis 2017년 7월 3일
편집: Image Analyst 2017년 7월 3일
The method does work I only added the '' to define the text (e.g. 'yourString')
Thank you very much appreciate your time
Image Analyst
Image Analyst 2017년 7월 3일
You're welcome, and thanks for Accepting the answer. In my code yourString was meant to be your variable name that contains the string. If you want it to be the actual string -- what is called a "string literal" -- then, yes, you would have to enclose it in single quotes.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by