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
0 个评论
回答(1 个)
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 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!