Effacer les filtres
Effacer les filtres

strings in conditional statments

3 vues (au cours des 30 derniers jours)
ali altaif
ali altaif le 5 Oct 2022
Commenté : ali altaif le 6 Oct 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

Réponse acceptée

Chunru
Chunru le 5 Oct 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
  1 commentaire
ali altaif
ali altaif le 6 Oct 2022
I apprechate you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by