Using variables to name excel worksheets.

조회 수: 3 (최근 30일)
Joseph
Joseph 2011년 4월 7일
Hello,
I was wondering if it was possible to use the xlswrite function in a way that the name of the sheet I am writing to could have the name of a current variable.
So for instance if I am changing the value of delta = x, I would have the xlswrite function say something like:
xlswrite('excelfile.xls', output, 'Delta ='x)
So that the output is written in a new sheet called Delta = x, but the value of x changes obviously.
Is this possible? I tried searching through to see if this question had been answered already, but couldn't find a relevant answer...
Thanks in advance!

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 4월 7일
If x is a number then you have to convert it into a string first:
x = 10;
xlswrite('excelfile.xls', 10, ['Delta =' sprintf('%d',x)])
  댓글 수: 1
Joseph
Joseph 2011년 4월 7일
Thanks so much, works perfectly!

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

추가 답변 (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