I have 2 vectors and i want to obtain a correlation between them like y=ax+b by using regression, but i don't know how to use this code. would anyone help me with this?

 채택된 답변

Walter Roberson
Walter Roberson 2017년 3월 12일

0 개 추천

coeffs = polyfit(FirstVector, SecondVector, 1);
Then coeffs(1) will be your a, and coeffs(2) will be your b.

댓글 수: 4

Ghazal Hnr
Ghazal Hnr 2017년 3월 12일
Isn't any way to write with regression code?
That is regression code.
A different way of writing the same thing:
A = [FirstVector(:), ones(numel(FirstVector),1)];
b = SecondVector(:);
coeffs = A\b;
Ghazal Hnr
Ghazal Hnr 2017년 3월 12일
thank you very much
Walter Roberson
Walter Roberson 2017년 3월 12일
Note that when I say "a different way of writing the same thing", I mean that polyfit() really does construct those matrices and use the \ operator.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Descriptive Statistics and Insights에 대해 자세히 알아보기

질문:

2017년 3월 12일

댓글:

2017년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by