# Have values display based on user input

4 views (last 30 days)
Forza on 2 Dec 2020
Commented: Rena Berman on 6 May 2021
I am trying to have my function to prompt the user to enter a word and have values display based on the word entered. I am not sure exactly how do I move foward from this?
function [T_mp,rho,cp,k,alpha] = Material_Properties(MN)
T_mp_vec = [1406 2192 693 2125]';
rho_vec = [19070 6100 7140 6570]';
cp_vec = [116 489 389 278]';
k_vec = [27.6 30.7 116 22.7]';
a_vec = [12.5 10.3 41.8 12.4]'*1e-6;
if input('Uranium')
t_mp = T_mp_vec(1)
rho = rho_vec(1)
cp = cp_vec(1)
k = k_vec(1)
alpha = a_vec(1)
t_mp = T_mp_vec(2)
rho = rho_vec(2)
cp = cp_vec(2)
k = k_vec(2)
alpha = a_vec(2)
end
end
end
##### 2 CommentsShowHide 1 older comment
Rena Berman on 6 May 2021
(Answers Dev) Restored edit

Walter Roberson on 2 Dec 2020
function [T_mp,rho,cp,k,alpha] = Material_Properties(MN)
T_mp_vec = [1406 2192 693 2125]';
rho_vec = [19070 6100 7140 6570]';
cp_vec = [116 489 389 278]';
k_vec = [27.6 30.7 116 22.7]';
a_vec = [12.5 10.3 41.8 12.4]'*1e-6;
material = input("Pick a card, any card!", 's');
switch lower(material)
case 'uranium':
t_mp = T_mp_vec(1);
rho = rho_vec(1);
cp = cp_vec(1);
k = k_vec(1);
alpha = a_vec(1);
t_mp = T_mp_vec(2);
rho = rho_vec(2);
cp = cp_vec(2);
k = k_vec(2);
alpha = a_vec(2);
otherwise
error('You were not supposed to pick THAT card!');
end
end
By the way, what is the purpose of the MN input the user can pass in?
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 2 Dec 2020
"So MN is just like a place holder, kind of. What im trying to do it have the code ask the user to enter between Uranium or vanadium, and output values based on either of the choices. I hope this made more sense."