Regression

조회 수: 7 (최근 30일)
Farz Tak
Farz Tak 2012년 2월 9일
답변: Maria Ghani 2022년 10월 19일
How can we display the regression equation (obtained by camand "fit") in the plot?

채택된 답변

the cyclist
the cyclist 2012년 2월 9일
Here is an example:
x = (1:20)';
y = 2 + 3*x + 7*rand(20,1);
model = fit(x,y,'poly1')
figure
plot(model,x,y)
The plot command here is an "overloaded" method for cfit objects (the output of the fit command). The documentation is here: http://www.mathworks.com/help/toolbox/curvefit/plot.html
  댓글 수: 1
Farz Tak
Farz Tak 2012년 2월 14일
Thanks a lot, That was helpful

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Richard Willey
Richard Willey 2012년 2월 9일
Try the following
X = linspace(1, 2*pi, 50);
X = X';
Y = sin(X) + randn(50,1);
foo = fit(X,Y, 'sin1');
figure1 = figure;
scatter(X,Y)
hold on
plot(foo)
% Create textbox
annotation(figure1,'textbox',...
[0.147443514644351 0.802739726027397 0.305903765690377 0.0931506849315069],...
'String',{[formula(foo)]},...
'FitBoxToText','off',...
'BackgroundColor',[1 1 1]);
  댓글 수: 1
Farz Tak
Farz Tak 2012년 2월 14일
This really helps me and even save me from using text command every time. Thanks. That was exactly what I wanted to know about this question.

댓글을 달려면 로그인하십시오.


Maria Ghani
Maria Ghani 2022년 10월 19일
. i need to run regression to get coeffecient between two variables x, y . my data set is daily from 1995 to 2022 . i need monthly coeffecient between two variables . what command should i need to write please anyone help. my dat afile is attached for detail information. x regress y but how i can get for every month ?
thanks in advance

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by