strings in conditional statments

3 次查看(过去 30 天)
Hello
I am trying to use a user input string 'yes' in a conditional statment. but can get it to work for me, any idea how can do this?
thanks in advance
% Taylor Series
syms a q w e r t y u i o p a s d f g h j k l z x c v b n m
y = input('Enter the exprestion to approximate: ');
a = input('Enter A symobol of the variable: ');
b = input('Enter At what: ');
c = input('Enter the number of terms: ');
TaylorSeries = taylor(y,a,b,'order', c) % taylor series expantion function
l = input('Do you want to plot: ');
if l == 'yes'
taylortool(TaylorSeries)
else
fprintf('alright')
end

采纳的回答

Chunru
Chunru 2022-10-5
l = input('Do you want to plot: ', "s"); % s for string
if l == "yes" % string comparison instead of char; 'yes'
taylortool(TaylorSeries)
else
fprintf('alright')
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by