MATLAB代码,求修改clcx=[20 29 41\x0541 48 48 53\x0554 56 57 60\x0563 67 71 75 80\x0583 88 100 101]';y=[1.0 0.93\x050.68 0.81 0.58 0.60\x050.59 0.48 0.52 0.46 0.42 0.60 0.36 0.55\x050.40 0.46 0.48 0.38 0.41 0.37]';P=polyfit(log(x),log(y),1);X=x(1)

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 22:17:05

MATLAB代码,求修改clcx=[20 29 41\x0541 48 48 53\x0554 56 57 60\x0563 67 71 75 80\x0583 88 100 101]';y=[1.0 0.93\x050.68 0.81 0.58 0.60\x050.59 0.48 0.52 0.46 0.42 0.60 0.36 0.55\x050.40 0.46 0.48 0.38 0.41 0.37]';P=polyfit(log(x),log(y),1);X=x(1)
MATLAB代码,求修改
clc
x=[20 29 41\x0541 48 48 53\x0554 56 57 60\x0563 67 71 75 80\x0583 88 100 101]';
y=[1.0 0.93\x050.68 0.81 0.58 0.60\x050.59 0.48 0.52 0.46 0.42 0.60 0.36 0.55\x050.40 0.46 0.48 0.38 0.41 0.37]';
P=polyfit(log(x),log(y),1);
X=x(1):0.01:x(end);
Y=(exp(P(2)))*xx.^(P(1));
plot(x,y,'o',X,Y)
这个是居民地选取指标的一元回归模型,为何不能运行.
要求是:
Y和X的关系可用幂函数来表示:
Y=a•Xb
根据以上所给数据建立居民地选取程度Y和实地密度X的一元回归模型,求出系数a和b,并对该非线性回归方程的显著性进行检验.

MATLAB代码,求修改clcx=[20 29 41\x0541 48 48 53\x0554 56 57 60\x0563 67 71 75 80\x0583 88 100 101]';y=[1.0 0.93\x050.68 0.81 0.58 0.60\x050.59 0.48 0.52 0.46 0.42 0.60 0.36 0.55\x050.40 0.46 0.48 0.38 0.41 0.37]';P=polyfit(log(x),log(y),1);X=x(1)
在7.1以上版中,可用:
x=[20 29 4141 48 48 5354 56 57 6063 67 71 75 8083 88 100 101]';
y=[1.0 0.930.68 0.81 0.58 0.600.59 0.48 0.52 0.46 0.42 0.60 0.36 0.550.40 0.46 0.48 0.38 0.41 0.37]';
xData = x(:);
yData = y(:);
% Set up fittype and options.
ft = fittype( 'a*x^b', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( ft );
opts.Display = 'Off';
opts.StartPoint = [0.913375856139019 0.63235924622541];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts )
x1=[20:0.1:110];
h_ = plot( x1, fitresult(x1), xData, yData, '* ' );
legend off; % turn off legend from plot method call
set(h_(1),'Color',[1 0 0],...
'LineStyle','-', 'LineWidth',2,...
'Marker','none', 'MarkerSize',6);
h = legend('拟合曲线','原始数据',2,'Location','Best');
set(h,'Interpreter','none')
title('拟合图 原始数据')
xlabel( 'x' );
ylabel( 'y' );