Random points on a curve

I have 2 arrays representing sets of data for velocity (Vx) and time (t) given. I get a curve by simply plotting them against each other. I want to take random points on this curve. How do I do it?

回答 (2 件)

Matt J
Matt J 2023 年 9 月 24 日

0 投票

Youc an interpolate the curve at random points using interp1.
Torsten
Torsten 2023 年 9 月 24 日

0 投票

mat = load("Vx and t.mat")
t = mat.t;
Vx = mat.Vx;
hold on
plot(t,Vx)
n = 100; % number of random points
r = rand(n,1);
random_values_t = min(t)*r + (max(t)-min(t))*(1-r);
random_values_Vx = interp1(t,Vx,random_values_t);
plot(random_values_t,random_values_Vx,'o','color','k')

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

質問済み:

2023 年 9 月 24 日

回答済み:

2023 年 9 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by