필터 지우기
필터 지우기

strings in conditional statments

조회 수: 3 (최근 30일)
ali altaif
ali altaif 2022년 10월 5일
댓글: ali altaif 2022년 10월 6일
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