⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parafit.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:
%FUNCTION PARAFIT finds the parabola polynomial function that fits the given
%         two points.
%         
% [cof,yi]=parafit(x,y,factor,xi);
% INPUT :   [x(1) x(2)] and [y(1) y(2)] are the given two knobs 
%           factor == 1 set the parabola max/min at (x1,y1)
%                       otherwise set the parabola max/min at (x2,y2)
%           xi == new abscissa vector
%             
% OUTPUT :   cof == the coefficients that describe the cubic polynomial 
%             yi == the corresponding vector to xi

%
%       where  y= cof(1)*x^2+cof(2)*x+cof(3)

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

x1=x(1);  x2=x(2);
y1=y(1);  y2=y(2);

if factor==1   %% y=a*(x-x1)^2+y1

     a=(y2-y1)/(x1-x2)/(x1-x2);
     cof=[a -2*a*x1 a*x1*x1+y1];

else           %% y=a*(x-x2)^2+y2

     a=(y1-y2)/(x1-x2)/(x1-x2);
     cof=[a -2*a*x2 a*x2*x2+y2];
end

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

⌨️ 快捷键说明

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