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

 Respuesta aceptada

Stephen23
Stephen23 el 24 de En. de 2017
Editada: Stephen23 el 24 de En. de 2017

0 votos

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 comentarios

ehsan Zahoor
ehsan Zahoor el 24 de En. de 2017
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 el 24 de En. de 2017
OMG YOU ARE THE BEST! thank you so so much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de En. de 2017

Comentada:

el 24 de En. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by