matlab中的一元回归我在matlab中输入如下程序function[x,y]=DataRegress1xx=[2.38 2.44 2.70 2.98 3.32 3.12 2.14 2.86 3.50 3.20 2.78 2.70 2.36 2.42 2.62 2.80 2.92 3.04 3.26 2.30];yy=[51.11 50.63 51.82 52.97 54.47 53.33 49.90 51.99 55.81 52.9
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 09:56:32
matlab中的一元回归我在matlab中输入如下程序function[x,y]=DataRegress1xx=[2.38 2.44 2.70 2.98 3.32 3.12 2.14 2.86 3.50 3.20 2.78 2.70 2.36 2.42 2.62 2.80 2.92 3.04 3.26 2.30];yy=[51.11 50.63 51.82 52.97 54.47 53.33 49.90 51.99 55.81 52.9
matlab中的一元回归
我在matlab中输入如下程序
function[x,y]=DataRegress1
xx=[2.38 2.44 2.70 2.98 3.32 3.12 2.14 2.86 3.50 3.20 2.78 2.70 2.36 2.42 2.62 2.80 2.92 3.04 3.26 2.30];
yy=[51.11 50.63 51.82 52.97 54.47 53.33 49.90 51.99 55.81 52.93 52.87 52.36 51.38 50.87 51.02 51.29 52.73 52.81 53.59 49.77];
[x,index]=sort(xx);
y=yy(index);
[x,y]=DataRegress1;
[c,s]=polyfit(x,y,1);
[yhat,w]=polyconf(c,x,s,.05);
syy=sum(y.^2)-length(x)*mean(y)^2;
sse=syy-c(1)*(sum(x.*y)-length(x)*mean(x)*mean(y));
plot(x,yhat,'k-',x,yhat-w,'k--',x,yhat+w,'k- -',x,y,'ks',[x;x],[yhat;y],'k-')
legend('Regression line','95% confidence of y',4)
axis([2 3.6 57])
xlabel('x(input)')
ylabel('y(reponse)')
titel('simple linear regression')
text(2.1,56,['coefficient of determination R^2=' num2str(1-sse/syy,3)])
来进行一元回归,可执行的时候弹出如下对话
Maximum recursion limit of 500 reached.Use set(0,'RecursionLimit',N)
to change the limit.Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> C:\MATLAB6p5p1\progarm\DataRegress1.m
On line 7 ==> [x,y]=DataRegress1;
执行不出意料中的图,请问是上面的提示是什么意思,应该如何解决啊,万谢!
matlab中的一元回归我在matlab中输入如下程序function[x,y]=DataRegress1xx=[2.38 2.44 2.70 2.98 3.32 3.12 2.14 2.86 3.50 3.20 2.78 2.70 2.36 2.42 2.62 2.80 2.92 3.04 3.26 2.30];yy=[51.11 50.63 51.82 52.97 54.47 53.33 49.90 51.99 55.81 52.9
改了4处,程序通了,见程序批注.
function[x,y]=DataRegress1
xx=[2.38 2.44 2.70 2.98 3.32 3.12 2.14 2.86 3.50 3.20 2.78 2.70 2.36 2.42 2.62 2.80 2.92 3.04 3.26 2.30];
yy=[51.11 50.63 51.82 52.97 54.47 53.33 49.90 51.99 55.81 52.93 52.87 52.36 51.38 50.87 51.02 51.29 52.73 52.81 53.59 49.77];
[x,index]=sort(xx)
y=yy(index)
%[x,y]=DataRegress1; %useless sentance
[c,s]=polyfit(x,y,1);
[yhat,w]=polyconf(c,x,s,.05);
syy=sum(y.^2)-length(x)*mean(y)^2;
sse=syy-c(1)*(sum(x.*y)-length(x)*mean(x)*mean(y));
plot(x,yhat,'k-',x,yhat-w,'k--',x,yhat+w,'k--',x,y,'ks',[x;x],[yhat;y],'k-') %yhat+w,'k--' NOT yhat+w,'k- -'
legend('Regression line','95% confidence of y',4)
axis([2 3.6 48 57]) %Ymin=48 absent
xlabel('x(input)')
ylabel('y(reponse)')
title('simple linear regression') %title NOT titel
text(2.1,56,['coefficient of determination R^2=' num2str(1-sse/syy,3)])