필터 지우기
필터 지우기

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 CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by