Newton-Raphson Method Error

조회 수: 1 (최근 30일)
mPackEE
mPackEE 2015년 2월 19일
답변: Meysam Mahooti 2019년 12월 5일
I have created a function to do Newton-Raphson method on a gas law problem. Supposedly, you enter pressure, temperature, and receive the specific volume as a result. Unfortunately, I only seem to be receiving one of my constants as the output. I can't seem to find where I went wrong. Any help?
function result=MyNewtonFn(p,t)
a=0.1747;
b=0.00138;
r=0.29681;
l(1)=1;
function u=fun(x)
u=(p+a./x.^2).*(x-b)/(r*t);
end
function w=der(q)
w= (p + a./q.^2)/(r*t) + (2*a.*(b - q))/(r*t.*q^3);
end
for v=1:1000
l(v+1)=l(v)-(fun(l(v))/(der(l(v))));
err(v)=abs((l(v+1)-l(v))/(l(v)));
if err(v)<=0.01
break
end
end
result=l(v+1)
end

답변 (1개)

Meysam Mahooti
Meysam Mahooti 2019년 12월 5일

카테고리

Help CenterFile Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by