How to do input correctly

1 visualización (últimos 30 días)
Emilia
Emilia el 9 de Nov. de 2020
Comentada: Emilia el 9 de Nov. de 2020
clc;
clear;
Metal=input('Choose a metal material:');
if Metal==AISI1020
else S_y=427; G=80,000; v=0.29; E=207,000
if Metal==Alloy6061-T6
else S_y=276; G=26,000; v=0.33; E=69,000
if Metal==SAE4340
else S_y=910; G=83,000; v=0.29; E=214,000
end
end
end
Hello,
I want to choose material that input, but have there is an error problem.
Thanks for helping :)

Respuestas (1)

Stephen23
Stephen23 el 9 de Nov. de 2020
Metal = input('Choose a metal material:','s');
switch Metal
case 'AISI1020'
S_y = 427;
G = 80.000; % decimal comma changed to decimal point
v = 0.29;
E = 207.000; % decimal comma changed to decimal point
case 'Alloy6061-T6'
S_y = 276;
G = 26.000; % decimal comma changed to decimal point
v = 0.33;
E = 69.000; % decimal comma changed to decimal point
case 'SAE4340'
S_y = 910;
G = 83.000; % decimal comma changed to decimal point
v = 0.29;
E = 214.000; % decimal comma changed to decimal point
otherwise
error('unknown input')
end
  2 comentarios
the cyclist
the cyclist el 9 de Nov. de 2020
@Emilia, you might also want to consider using a different input function, such as listdlg, to save your user the error-prone task of typing out the full name. You can present them with a pre-defined list instead.
Emilia
Emilia el 9 de Nov. de 2020
Ok I will try this method too. Thanks to @Stephen Cobeldick and @the cyclist :)

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by