function [c,R2,rout] = fitqr(x,y,basefun)
% fitqr Least-squares fit via solution of overdetermined system with QR
% Given ordered pairs of data, (x_i,y_i), i=1,...,m, fitqr
% returns the vector of coefficients, c_1,...,c_n, such that
% F(x) = c_1*f_1(x) + c_2*f_2(x) + ... + c_n*f_n(x)
% minimizes the L2 norm of y_i - F(x_i).
%
% Synopsis: c = fitqr(x,y,basefun)
% [c,R2] = fitqr(x,y,basefun)
% [c,R2,r] = fitqr(x,y,basefun)
%
% Input: x,y = vectors of data to be fit
% basefun = (string) name of user-supplied m-file that computes
% matrix A. The columns of A are the values of the
% basis functions evaluated at the x data points.
%
% Output: c = vector of coefficients obtained from the fit
% R2 = (optional) adjusted coefficient of determination; 0 <= R2 <= 1
% R2 close to 1 indicates a strong relationship between y and x
% r = (optional) residuals of the fit
if length(y)~= length(x); error('x and y are not compatible'); end
A = feval(basefun,x(); % Coefficient matrix of overdetermined system
c = A\y(; % Solve overdetermined system with QR factorization
if nargout>1
r = y - A*c; % Residuals at data points used to obtain the fit
[m,n] = size(A);
R2 = 1 - (m-1)/(m-n-1)*(norm(r)/norm(y-mean(y)))^2;
if nargout>2, rout = r; end
end
fitqr.rar_QR分解算法_fit$qr_qr分解_总体最小二乘
版权申诉
15 浏览量
2022-09-21
04:23:50
上传
评论
收藏 1KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/9116002996824fde940a716bee54aca8_weixin_42663213.jpg!1)
钱亚锋
- 粉丝: 90
- 资源: 1万+
最新资源
- 使用ASP.NET Core和Entity Framework Core来构建一个基本的进销存系统.rar
- 深度学习经典数据集+FER2013面部表情识别+附带使用方法的python代码
- Python中,要实现连接多个相机并识别多个二维码.rar
- 使用FFT算法对一个信号进行分析.rar
- 171cms游戏应用下载系统源码.zip
- 基于jsp+servlet+mysql蛋糕甜品店购物网站源码+数据库(期末大作业).zip
- Java项目:在线蛋糕商城系统(java+jsp+mysql)源码+数据库+期末大作业.zip
- ZapyaClient10_7-1.apk
- 织梦cms站长导航网站源码.zip
- 基于SSM+MySQL的网络投票调查问卷系统源码+数据库(java期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)