f=input('f(v)=');
n=input('n=');
v0=input('v0=');
f1=diff(f);
for i=1:n
v=v0;
f(v0)=eval(f);
f1(v0)=eval(f1);
v0=v0-f(v0)/f1(v0);
end
结果为:
f(v)='37382-(-0.08v-259.08*log(1-0.08v/259.08))-91.4'
n=6
v0=11
错误使用 ff2 (line 7)
错误: 不应为 MATLAB 表达式。
使用的是64位的R2014a,系统win7.

 Accepted Answer

clear
syms v
f=input('f(v)=','s');
n=input('n=');
v0=input('v0=');
f1=diff(eval(f),v);
for i=1:n
    fv0=subs(eval(f),v0);
    fdv0=subs(f1,v0);
    v0=v0-fv0/fdv0;
end
[double(v0) double(subs(eval(f),v0))]

More Answers (0)

Categories

Find more on MATLAB 快速入门 in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!