您现在的位置:首页 >> 技术文章 >> 数值分析 >> 内容

最小均方跟数据拟合*matlab代做

时间:2017-4-27 2:41:34 点击:

  核心提示:最小均方跟数据拟合*matlab代做...

最小均方跟数据拟合

function [ YI ] = lsq_lut_piecewise( x, y, XI )
% LSQ_LUT_PIECEWISE Piecewise linear interpolation for 1-D interpolation (table lookup)
%   YI = lsq_lut_piecewise( x, y, XI ) obtain optimal (least-square sense)
%   vector to be used with linear interpolation routine.
%   The target is finding Y given X the minimization of function
%           f = |y-interp1(XI,YI,x)|^2
%  
%   INPUT
%       x measured data vector
%       y measured data vector
%       XI break points of 1-D table
%
%   OUTPUT
%       YI interpolation points of 1-D table
%           y = interp1(XI,YI,x)
%


if size(x,2) ~= 1
    error('Vector x must have dimension n x 1.');  
elseif size(y,2) ~= 1
    error('Vector y must have dimension n x 1.');   
elseif size(x,1) ~= size(x,1)
    error('Vector x and y must have dimension n x 1.');
end

% matrix defined by x measurements
A = sparse([]);

% vector for y measurements
Y = [];

for j=2:length(XI)
   
    % get index of points in bin [XI(j-1) XI(j)]
    ix = x>=XI(j-1) & x<XI(j);
   
    % check if we have data points in bin
    if ~any(ix)
        warning(sprintf('Bin [%f %f] has no data points, check estimation. Please re-define X vector accordingly.',XI(j-1),XI(j)));
    end
   
    % get x and y data subset
    x_ = x(ix);
    y_ = y(ix);
   
    % create temporary matrix to be added to A
    tmp = [(( -x_+XI(j-1) ) / ( XI(j)-XI(j-1) ) + 1) (( x_-XI(j-1) ) / ( XI(j)-XI(j-1) ))];
   
    % build matrix of measurement with constraints
    [m1,n1]=size(A);
    [m2,n2]=size(tmp);
    A = [[A zeros(m1,n2-1)];[zeros(m2,n1-1) tmp]];
   
    % concatenate y measurements of bin
    Y = [Y; y_];
end

% obtain least-squares Y estimation
YI=A\Y;

 

作者:最小均方跟数据拟合 来源:最小均方跟数据拟合
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关文章
  • 没有相关文章
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做(www.hslogic.com) © 2018 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment