matlab非线性回归x = [0,1,3,5,10,24],y = [1,1.4,4.5,3.5,2.1,1.3],函数可能是y=a*x^3+b*x^2+c*x^1+d.麻烦达人们帮我解一下a,b,c,d参数.如果能把命令也一起告诉我就更加感谢了!
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/02 19:22:37
matlab非线性回归x = [0,1,3,5,10,24],y = [1,1.4,4.5,3.5,2.1,1.3],函数可能是y=a*x^3+b*x^2+c*x^1+d.麻烦达人们帮我解一下a,b,c,d参数.如果能把命令也一起告诉我就更加感谢了!
matlab非线性回归
x = [0,1,3,5,10,24],y = [1,1.4,4.5,3.5,2.1,1.3],函数可能是y=a*x^3+b*x^2+c*x^1+d.麻烦达人们帮我解一下a,b,c,d参数.如果能把命令也一起告诉我就更加感谢了!
matlab非线性回归x = [0,1,3,5,10,24],y = [1,1.4,4.5,3.5,2.1,1.3],函数可能是y=a*x^3+b*x^2+c*x^1+d.麻烦达人们帮我解一下a,b,c,d参数.如果能把命令也一起告诉我就更加感谢了!
http://hi.baidu.com/zzz700/blog/item/ec1b4d134e155b4cf2de3277.html
以下代码在7.1版以上均可运行.
close all
clear,clc
x = [0, 1, 3, 5, 10, 24];
y = [1, 1.4, 4.5, 3.5, 2.1, 1.3];
xData = x';
yData = y';
% Set up fittype and options.
ft = fittype( 'a*x^3+b*x^2+c*x^1+d', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.StartPoint = [0.795199901137063 0.186872604554379 0.489764395788231 0.445586200710899];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts )
% Plot fit with data.
figure( 'Name', '拟合图' );
h_ = plot( fitresult, x, y, '* '); % 拟合图 原始数据
legend off; % turn off legend from plot method call
set(h_(2),'Color',[1 0 0],...
'LineStyle','-', 'LineWidth',2,...
'Marker','none', 'MarkerSize',6);
h = legend('原始数据','拟合曲线',2,'Location','Best');
set(h,'Interpreter','none')
title('拟合图 原始数据')
% Label axes
xlabel( 'x' );
ylabel( 'y' );
grid on
.
计算结果:
General model:
fitresult(x) = a*x^3+b*x^2+c*x^1+d
Coefficients (with 95% confidence bounds):
a = 0.005205 (-0.003479, 0.01389)
b = -0.1843 (-0.4727, 0.1041)
c = 1.447 (-0.6652, 3.56)
d = 0.7761 (-2.473, 4.025)