Unrecognized function errors MATLAB
Show older comments
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
Answers (1)
KSSV
on 5 May 2021
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
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!