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 件のコメント

Image Analyst
Image Analyst 2015 年 2 月 15 日
Try using && instead of &, like this:
while (testPerformance > 9 && valperformance >9)
ii = ii+1;
% other code....
end
Abdulaziz Abutunis
Abdulaziz Abutunis 2017 年 4 月 14 日
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 ExchangeLoops 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