Can MATLAB create a linear graph from polynomial graph?

1 回表示 (過去 30 日間)
Volkan Yangin
Volkan Yangin 2016 年 10 月 1 日
回答済み: Jang geun Choi 2016 年 10 月 2 日
Hi everybody,
I have an elevation-distance graph on MATLAB and its type is polynominal and i must change the graph style from polynominal to linear for reckon without some values. I can use MATLAB Fitting Toolbox, but this operation takes too long time and i don't sure whether make an error or not. 
Can MATLAB create a linear graph automatically? Or Do i have to use Fitting Toolbox for this purpose?
Thanks...
  1 件のコメント
dpb
dpb 2016 年 10 月 1 日
Don't follow what it is you're wanting do do here precisely, sorry. You mean you would want to approximate the above detailed very noisy curve with some linear piecewise sections, maybe? If so, how closely do you want the approximation to be--three gross sections good enough or what? To have a representation as is, probably the spline interpolant would be the choice--it'll have a lot of sections but those are essentially hidden from the user so doesn't really matter too much on the complexity.

サインインしてコメントする。

回答 (1 件)

Jang geun Choi
Jang geun Choi 2016 年 10 月 2 日
x=0:0.2:2*pi;
y=3*sin(x)+2*x+rand(size(x)); % example data
% linear regression
P=polyfit(x,y,1);
y2=polyval(P,x);
% Visualization
plot(x,y)
hold on
plot(x,y2,'r')

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by