How to do input correctly
조회 수: 1 (최근 30일)
이전 댓글 표시
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 :)
댓글 수: 0
답변 (1개)
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
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!