Error when selecting variables from an Excel sheet

조회 수: 2 (최근 30일)
Mohamed Ahmed
Mohamed Ahmed 2022년 4월 23일
댓글: Mohamed Ahmed 2022년 4월 23일
The code line
opts = spreadsheetImportOptions("VariableNamesRange",5, ...
"SelectedVariableNames",{'Sample Name'})
returns
Unknown variable name: 'Sample Name'.
opts = matlab.io.spreadsheet.SpreadsheetImportOptions(varargin{:});
Why am I receiving this error message? And any help to solve this problem will be much appreciated. Many thanks in advance.

채택된 답변

Simon Chan
Simon Chan 2022년 4월 23일
Better to define the Variable Names already in the spreadsheet as follows:
opts = spreadsheetImportOptions("VariableNamesRange",5, 'VariableNames',{'Var1','Var2','Sample Name','Var3'}...
"SelectedVariableNames",{'Sample Name'})
  댓글 수: 1
Mohamed Ahmed
Mohamed Ahmed 2022년 4월 23일
Yes, thank you Simon. I'll do that. Much appreciated.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by