How to discretize non-uniformally a curve

1 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2021-9-6
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.
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by