cubfit.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 30 行

M
30 行
字号
%FUNCTION CUBFIT finds the cubic polynomial to fit the given two points.
%         
% [cof,yi]=cubfit(x,y,xi);
% INPUT :   [x(1) x(2)] and [y(1) y(2)] are the given two knobs 
%           xi == new abscissa vector
%             
% OUTPUT :     yi == the corresponding vector to xi
%             cof == the coefficients that describe the cubic polynomial
%
%       where, w(t)= cof(1)*x^3+cof(2)*x^2+cof(3)*x+cof(4)

function [cof,yi]=cubfit(x,y,xi)

% 1.  construct the matrix
x1=x(1);
x2=x(2);

A=[x1^3   x1^2 x1 1;
   x2^3   x2^2 x2 1;
   3*x1^2 2*x1 1  0;
   3*x2^2 2*x2 1  0];

Y=[y(1); y(2); 0; 0];

cof=inv(A)*Y;

if nargout>1
   yi=polyval(cof,xi);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?