Unrecognized function errors MATLAB

4 次查看(过去 30 天)
Please help me solve the unrecognized errors line 18-29
prompt = ["input wet or dry:","What value do you want to find [time/thickness]:", "input the temperature in Kelvin:","enter index"];
dlgtitle = 'Values';
dims = [1 35];
answer = inputdlg(prompt,dlgtitle,dims);
global index %%creates popup display
global T
global kB
global X
str = string(answer{1}); %%creates string
str2 = string(answer{2});
T = str2num(answer{3});
index = string(answer{4}); %%creates index
kB = 8.617*10^-5; %%constant value kB
if str == 'wet' && str2 == "thickness" %%time and thickness
fprintf ("you want to find wet time!")
wettime(X)
elseif str == "wet" && str2 == "time"
fprintf ("you want to find wet thick!")
wetthick(X)
elseif str == "dry" && str2 == "thickness"
fprintf ("you want to find dry time!")
drytime(X)
elseif str == "dry" && str2 == "time"
fprintf ("you want to find dry thick!")
drythick(X)
else
fprintf ("input not understood try again")
end

回答(1 个)

KSSV
KSSV 2021-5-5
To compare two strings use strcmp. Read about it.
prompt = ["input wet or dry:","What value do you want to find [time/thickness]:", "input the temperature in Kelvin:","enter index"];
dlgtitle = 'Values';
dims = [1 35];
answer = inputdlg(prompt,dlgtitle,dims);
global index %%creates popup display
global T
global kB
global X
str = string(answer{1}); %%creates string
str2 = string(answer{2});
T = str2num(answer{3});
index = string(answer{4}); %%creates index
kB = 8.617*10^-5; %%constant value kB
if strcmp(str,'wet') && strcmp(str2,"thickness") %%time and thickness
fprintf ("you want to find wet time!")
wettime(X)
elseif strcmp(str,"wet") && strcmp(str2,"time")
fprintf ("you want to find wet thick!")
wetthick(X)
elseif strcmp(str,"dry") && strcmp(str2,"thickness")
fprintf ("you want to find dry time!")
drytime(X)
elseif strcmp(str,"dry") && strcmp(str2,"time")
fprintf ("you want to find dry thick!")
drythick(X)
else
fprintf ("input not understood try again")
end
  2 个评论
Toriano Thomas
Toriano Thomas 2021-5-5
Thank you, unfortunately, the issue persists!
KSSV
KSSV 2021-5-5
编辑:KSSV 2021-5-5
wetthick and drythick should be a variable or function...this you should be knowing.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by