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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by