Why does my variable not run through as a string?

조회 수: 2 (최근 30일)
Joseph
Joseph 2014년 11월 14일
댓글: Star Strider 2018년 6월 25일
Whenever I run my function to load a name and return an excel file for that name, I get this error:
Error using xlsread (line 122) Filename must be a string.
Error in loadNCIR (line 9) [~,vaccineName,~] = xlsread(excel);
function [Name] = loadName( Name )
excel = inputdlg(['Please enter the name for the ' Name ' xls file: ']...
,'s');
if strcmp(excel, '') == 1;
Name = {};
else
[~,Name,~] = xlsread(excel);
end
What am I doing wrong? My input is a variable for a string, and the output should be the excel file.

채택된 답변

Star Strider
Star Strider 2014년 11월 14일
The inputdlg function returns a cell. Use char to convert it to a string variable:
excelstr = char(excel);
  댓글 수: 2
Leopoldo Campos Carrillo
Leopoldo Campos Carrillo 2018년 6월 25일
Thanks man i apreciate!!!
Star Strider
Star Strider 2018년 6월 25일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by