Effacer les filtres
Effacer les filtres

How to discretize non-uniformally a curve

1 vue (au cours des 30 derniers jours)
Christos Patrinos
Christos Patrinos le 6 Sep 2021
Commenté : Star Strider le 6 Sep 2021
Hello,
Let's assume I have the following curves (see smooth solid lines) and I want to discretize them. I know about the discretize function, but what I would want is to discretize them using variable steps (see lines in discretized pattern). I know the easiest way is to manually discretize them by putting all the points hard coded and generating the pattern, but my main question is if there is an automated way through which I could input the reference curve, the number of points and their respective durations and have the curves created automatically.
Many thanks.

Réponse acceptée

Star Strider
Star Strider le 6 Sep 2021
One option is the stairs function —
x = linspace(0, 400,50);
y = [exp(x/100); sin(x/100)-x/400];
figure
plot(x, y)
grid
figure
stairs(x, y(1,:))
[xb{1}, yb{1}] = stairs(x, y(1,:));
hold on
stairs(x, y(2,:))
[xb{2}, yb{2}] = stairs(x, y(2,:));
hold off
grid
GetData= [xb{1}(1:10) yb{1}(1:10)]
GetData = 10×2
0 1.0000 8.1633 1.0000 8.1633 1.0851 16.3265 1.0851 16.3265 1.1773 24.4898 1.1773 24.4898 1.2775 32.6531 1.2775 32.6531 1.3862 40.8163 1.3862
Experiment to get different results.
.
  2 commentaires
Christos Patrinos
Christos Patrinos le 6 Sep 2021
Thank you for your answer @Star Strider; I think it is a good starting point!
Star Strider
Star Strider le 6 Sep 2021
As always, my pleasure!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Elementary Math dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by