need help to code this cubic fit

2 ビュー (過去 30 日間)
Haris Hameed
Haris Hameed 2020 年 8 月 18 日
編集済み: Haris Hameed 2020 年 8 月 18 日
hello
i need some guidace to code the cubic fit optimization in matlab
i coded it initially like this
clc
clear all
syms X;
f=X.^4+2.*X+4;
d_dx = diff(f, X);
dd_dx = diff(d_dx, X);
i=2;
iter=10;
%xk=0;
xk(1)=0.1;
xk(2)=0.2;
u1=subs(d_dx,X,xk(1))+subs(d_dx,X,xk(2))-3*((subs(f,X,xk(1))-subs(f,X,xk(2)))/xk(1)-xk(2));
u2=sqrt(u1^2-subs(d_dx,X,xk(1))*subs(d_dx,X,xk(2)));
xk(3)=xk(2)-(xk(2)-xk(1))*((subs(d_dx,X,xk(2))+u2-u1)/((subs(d_dx,X,xk(2)))-(subs(d_dx,X,xk(1)))+2*u2));
while i<iter
i=i+1;
u1=subs(d_dx,X,xk(i-1))+subs(d_dx,X,xk(i))-3*((subs(f,X,xk(i-1))-subs(f,X,xk(i)))/xk(i-1)-xk(i));
u2=sqrt(u1^2-subs(d_dx,X,xk(i-1))*subs(d_dx,X,xk(i)));
xk(i+1)=xk(i)-(xk(i)-xk(i-1))*((subs(d_dx,X,xk(i))+u2-u1)/((subs(d_dx,X,xk(i)))-(subs(d_dx,X,xk(i-1)))+2*u2));
%
%
end
xk

回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by