Effacer les filtres
Effacer les filtres

How to do input correctly

2 vues (au cours des 30 derniers jours)
Emilia
Emilia le 9 Nov 2020
Commenté : Emilia le 9 Nov 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 :)

Réponses (1)

Stephen23
Stephen23 le 9 Nov 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 commentaires
the cyclist
the cyclist le 9 Nov 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 le 9 Nov 2020
Ok I will try this method too. Thanks to @Stephen Cobeldick and @the cyclist :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Encryption / Cryptography dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by