if else statement with strings
Mostrar comentarios más antiguos
I want to take the user input and check if it is:
if the user input 'high pass' -> calcute this equation:GpRC = tf(R*C,1 + R*C);
if the user input 'low pass' --> calcute this equation:GpRC = tf(1,1 + R*C);
and then plot the true statement
this is the code:
%Make the user choose the filter
msgout = 'Choose from (high pass / low pass) \n';
%Calculate the gain
filter_option = input(msgout);
if strcmp(filter_option,'high pass')
GpRC = tf(R*C,1 + R*C);
plot(f_c,GpRC)
elseif strcmp(filter_option,'low pass')
GpRC = tf(1,1 + R*C);
plot(f_c,GpRC)
else
disp('Error!')
end
3 comentarios
Riccardo Scorretti
el 7 de Mayo de 2022
You didn't ask a question. In MATLAB Answers, users ask a precise question on a technical issue concerning MATLAB.
Dyuman Joshi
el 7 de Mayo de 2022
What exactly is the problem you are facing?
Badr Al-Sabri
el 7 de Mayo de 2022
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Calendar en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!