필터 지우기
필터 지우기

How to do input correctly

조회 수: 1 (최근 30일)
Emilia
Emilia 2020년 11월 9일
댓글: Emilia 2020년 11월 9일
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 :)

답변 (1개)

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by