How to display answers using polyfit

조회 수: 2 (최근 30일)
Justin Rosinski
Justin Rosinski 2012년 10월 27일
Hello everyone.
I'm trying to use polyfit to analyze some data, I want a linear regression, but the slope of the line is small, approximately 1.33e-7, but when I use polyfit, it only returns the coefficient of slope as 0. How can I get it to display the true number?

답변 (3개)

Matt Fig
Matt Fig 2012년 10월 27일
편집: Matt Fig 2012년 10월 27일
How do you know the slop of the line before you do the fit? How noisy is the data?
This seems to work:
>> x = 0:1; y = [0 1.33e-7]+5;
>> pp = polyfit(x,y,1)
pp =
1.33e-007 5

Star Strider
Star Strider 2012년 10월 27일
편집: Star Strider 2012년 10월 28일
You may have scaling problems such that the slope and intercept may vary by several orders of magnitude. Experiment with:
format longE
to see if your regression coefficients will then display correctly. See format for details.

Jan
Jan 2012년 10월 27일
Perhaps you want to modify the display in the command line:
format long g

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by