Make matlab differentiate until the conditions are met?

조회 수: 1 (최근 30일)
Andy
Andy 2012년 10월 13일
I'm making an application for l'hopital's rule. As anyone with knowledge of calculus, you would differentiate the two functions until one of the functions gives a nonzero limit. My question is how can I do that.
This is the code I have so far:
function y=mylhopital(f,g)
syms x
while(limit(f,x,0)==0 & limit(g,x,0)==0)
f=diff(f(x));
g=diff(g(x));
end
y=limit(f,x,0)/limit(g,x,0);

채택된 답변

Matt Fig
Matt Fig 2012년 10월 13일
편집: Matt Fig 2012년 10월 13일
If you want to keep differentiating until only one of the functions has a nonzero limit, simply use:
(limit(f,x,0)==0 || limit(g,x,0)==0)
instead of:
(limit(f,x,0)==0 & limit(g,x,0)==0)
By the way, when somebody resolves one of your questions, please select their answer as accepted. You have now asked 4 questions and left them all unresolved even though people took the time to answer for you...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Quantum Mechanics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by