How to make the linear function
조회 수: 13(최근 30일)
표시 이전 댓글
first of all, on the simulation condition
pf(pf>0.06) =1;
pf(pf<0.05) =1e3;
the value of f are decrease from 1 to 0, but once the value f<0.05 then become 1e4 times
but this condition make the trasition value changed was high ( the ranges is 1-10K ) how to makes the condition (f<0.05) as linear function, so the trasition will smoothly decrease.
댓글 수: 2
채택된 답변
Walter Roberson
2022년 11월 11일
In order for it to be a linear function as you asked for, then you should take a list of all of the (x, y) coordinates that you want to preserve, and you should use polyfit() or equivalent to fit a polynomial to the points. It will probably end up having to be a high degree polynomial in order to fit the constant stretches on both ends. Once you fit a polynomial to your satisfaction, use polyval() to create new points.
If you have the Curve Fitting Toolbox, you may want to use cftool() to help with the fitting.
댓글 수: 4
Sam Chak
2022년 11월 11일
Hi @Agung Putra
Perhaps you need to clarify if the data points come from
- the solution from a dynamical system such as
, or
- a static function such as
, or
- a set of data in an observational study (cannot be expressed in an analytical equation).
MATLAB has different tools to handle different cases.
From spreadsheet on the image, the plot appears to be generated from a data set in a table. If this is Case #3, then read this article:
추가 답변(1개)
Sam Chak
2022년 11월 11일
Aha, I see... If you want to get rid of spikes and want a smooth transition, but not strictly linear, then you can consider adding a low-pass filter (signal terminology), or a 1st-order dynamics (just need to design the time constant to ensure that the transition is fast enough).
댓글 수: 0
참고 항목
범주
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!