Azzera filtri
Azzera filtri

strings in conditional statments

3 visualizzazioni (ultimi 30 giorni)
ali altaif
ali altaif il 5 Ott 2022
Commentato: ali altaif il 6 Ott 2022
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

Risposta accettata

Chunru
Chunru il 5 Ott 2022
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

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by