필터 지우기
필터 지우기

Retrieve just the slope in polyfit

조회 수: 3 (최근 30일)
daniel.x16
daniel.x16 2011년 12월 28일
I would like to return a vector containing just the slopes of various regressions so I can compare them. Right now I have a loop:
for i=1:n
slope{i}=polyfit(x,y(:,i),1)
end
However, this gives me a 1xn cell with each cell having a 1x2 double with slope AND intercept. I just want a nx1 vector containing the slopes. Any help would be greatly appreciated!

채택된 답변

daniel.x16
daniel.x16 2011년 12월 28일
for i=1:n
slope{i}=polyfit(x,y(:,i),1)(1)
end
  댓글 수: 1
Jan
Jan 2011년 12월 28일
Sorry, Daniel.x16, but this produces this error in Matlab 2009a and 2011b:
Error: ()-indexing must appear last in an index expression.

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

추가 답변 (1개)

daniel.x16
daniel.x16 2011년 12월 28일
Nevermind!
for i=1:n
slope(i)=polyfit(x,y(:,i),1)a(1)
end
Works.

카테고리

Help CenterFile Exchange에서 Support Vector Machine Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by