How to make two conditions for a while loop?

I'm making an application for L'hopitals rule so I need a while loop whenever the limit of f(x) and g(x) are both 0. How would I do that?
This is what I have
while(limit(a)=0 & limit(b)=0)

 채택된 답변

Wayne King
Wayne King 2012년 10월 13일
편집: Wayne King 2012년 10월 13일

1 개 추천

You need the == equals
while(x==0 & y==0)
For example:
syms x
y = x;
f = x^2;
if (limit(y,x,0)==0 & limit(f,x,0)==0)
disp('true');
else
disp('false');
end

추가 답변 (2개)

trinuj Vongsomtakul
trinuj Vongsomtakul 2015년 2월 15일
편집: Image Analyst 2015년 2월 15일

0 개 추천

How do I write
while (testPerformance > 9 & valperformance >9)
ii = ii+1;
in MATLAB? It is an error when i try to run it. I would like to stop the iteration when these 2 conditions are met.

댓글 수: 3

Try using && instead of &, like this:
while (testPerformance > 9 && valperformance >9)
ii = ii+1;
% other code....
end
I think this will keep repeating the loop not stopping it
Anom Sulardi
Anom Sulardi 2020년 6월 17일
while (testPerformance > 9 && valperformance >9)
ii = ii+1;
if ii==ii(end)
end
% other code....
end

댓글을 달려면 로그인하십시오.

Sebastian Arteaga
Sebastian Arteaga 2021년 11월 9일

0 개 추천

Con I do condition OR condition in a while loop?

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2012년 10월 13일

답변:

2021년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by