Clear Filters
Clear Filters

How to discretize non-uniformally a curve

1 view (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 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.
.

More Answers (0)

Categories

Find more on Elementary Math in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!