Filter löschen
Filter löschen

How to do input correctly

1 Ansicht (letzte 30 Tage)
Emilia
Emilia am 9 Nov. 2020
Kommentiert: Emilia am 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 :)

Antworten (1)

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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Encryption / Cryptography finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by