How to make the linear function

38 vues (au cours des 30 derniers jours)
Agung Putra
Agung Putra le 11 Nov 2022
Commenté : Sam Chak le 11 Nov 2022
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 commentaires
Sam Chak
Sam Chak le 11 Nov 2022
Best is to sketch out what the desired function looks like, and we can suggest how to build the math for it.
Some MATLAB functions do not require the input of math, only need to specify the critical points and then connect the dots to draw the line. This approach is more effective if you don't require the math for rigorous proof later.
Agung Putra
Agung Putra le 11 Nov 2022
Déplacé(e) : Walter Roberson le 11 Nov 2022
please kindly find the attached file

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Nov 2022
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 commentaires
Walter Roberson
Walter Roberson le 11 Nov 2022
I already told you how to do it: fit a polynomial to the points you want to preserve. That will ensure that you satisfy the condition that it is a linear function.
Sam Chak
Sam Chak le 11 Nov 2022
Perhaps you need to clarify if the data points come from
  1. the solution from a dynamical system such as , or
  2. a static function such as , or
  3. 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:

Connectez-vous pour commenter.

Plus de réponses (1)

Sam Chak
Sam Chak le 11 Nov 2022
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).

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by