Naming Excel Sheet with xlswrite.

조회 수: 19 (최근 30일)
Samuel Brewton
Samuel Brewton 2021년 2월 19일
편집: Samuel Brewton 2021년 2월 19일
I am looking to use xlswrite to export a matrix to excel. For the naming convention, I want to name it based on a variable (ex: x=30) so that the excel file would be named "Rule30.xls".
I've tried using xlswrite(FILE,ARRAY) as xlswrite( ('Rule%d',x) , matrix), similar to how I'd use fprintf.
Here would be a quick code example:
x=30 % Defines x
matrix = eye(x) % Creates an identity matrix that's x by x
xlswrite(('Rule%d',x),matrix) % Writes 'matrix' as an excel file titled 'Rule30.xls'

채택된 답변

Fangjun Jiang
Fangjun Jiang 2021년 2월 19일
FileName=['Rule',num2str(x)]
FileName=sprintf('Rule%d',x)
  댓글 수: 1
Samuel Brewton
Samuel Brewton 2021년 2월 19일
Both work perfect, thanks so much!

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by