Hi guys. please can someone help me locate and fix this error that i keep getting in my file.. i am trying to basically say that at the start the user defines if a plate is fixed or simply supported (simple). from here if it is defined as simple then all edges become 19 and corner becomes 18 and if user defines it to be fixed then all edges become 21 and corners become 22.For some reason it keeps giving an error. :( i have shown below the term Endcond which just stands for end condition of plate (simple of fixed)
Endcond= 'input'
Endcond=input('Enter simple or fixed')
if Endcond==('simple')
corner=18;
edge=19;
elseif Endcond==fixed
corner=22;
edge=21;
end
below is the error i keep getting...
Enter the apllied load (kN/m)20
Endcond =
input
Enter simple or fixedsimple Error using input Undefined function or variable 'simple'.
Error in corrected (line 14) Endcond=input('Enter simple or fixed')
Enter simple or fixed

 채택된 답변

Stephen23
Stephen23 2017년 1월 24일
편집: Stephen23 2017년 1월 24일

0 개 추천

You need to call input with the 's' option to get it to return a string (without this option is slow and a security risk anyway), and also use strcmp or strcmpi to check the strings:
str = input('Enter "simple" or "fixed": ','s');
if strcmpi(str,'simple')
corner = 18;
edge = 19;
elseif strcmpi(str,'fixed')
corner = 22;
edge = 21;
else
% what to do?
end
Alternatively you could use switch:
str = input('Enter "simple" or "fixed": ','s');
switch lower(str)
case 'simple'
corner = 18;
edge = 19;
case 'fixed'
corner = 22;
edge = 21;
otherwise
% what to do?
end

댓글 수: 2

ehsan Zahoor
ehsan Zahoor 2017년 1월 24일
Hi Stephen I am going to try this right now sir! thank you so much for replying i really appreciate it
ehsan Zahoor
ehsan Zahoor 2017년 1월 24일
OMG YOU ARE THE BEST! thank you so so much

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2017년 1월 24일

댓글:

2017년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by