How to fit ascending data with piecewise linear function?

3 ビュー (過去 30 日間)
xiaojuezi
xiaojuezi 2020 年 10 月 5 日
編集済み: Matt J 2020 年 10 月 6 日
Hi, I have a vector r sorted in asending order. Now I would like to fit this r with m+1 pieces, and extract the m internal points.
E.g, my data is:
r = [1,1.5,1.6,2,3,3.1,3.2,3.5]
If m = 2, then I can fit three lines to r, and the internal points are [2,3].
Is there a way to do this algorithmatically?
Thank you very much.
  1 件のコメント
Mathieu NOE
Mathieu NOE 2020 年 10 月 6 日
hello
could you please clarify what is your intention ? the internal points are supposed to correspond to the integer values in your data vector or what is the logic to choose which values are meaningfull in your linear piecewise interpolation ?

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

回答 (1 件)

Matt J
Matt J 2020 年 10 月 6 日
編集済み: Matt J 2020 年 10 月 6 日
There are some spline fitting tools on the file exchange that would be applicable:
Note that a piecewise linear function is a first-order spline.

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by