How to make two conditions for a while loop?

281 Ansichten (letzte 30 Tage)
Andy
Andy am 13 Okt. 2012
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)

Akzeptierte Antwort

Wayne King
Wayne King am 13 Okt. 2012
Bearbeitet: Wayne King am 13 Okt. 2012
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

Weitere Antworten (2)

trinuj Vongsomtakul
trinuj Vongsomtakul am 15 Feb. 2015
Bearbeitet: Image Analyst am 15 Feb. 2015
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 Kommentare
Abdulaziz Abutunis
Abdulaziz Abutunis am 14 Apr. 2017
I think this will keep repeating the loop not stopping it
Anom Sulardi
Anom Sulardi am 17 Jun. 2020
while (testPerformance > 9 && valperformance >9)
ii = ii+1;
if ii==ii(end)
end
% other code....
end

Melden Sie sich an, um zu kommentieren.


Sebastian Arteaga
Sebastian Arteaga am 9 Nov. 2021
Con I do condition OR condition in a while loop?

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by