Filter löschen
Filter löschen

Generate clusters of points which are periodically spaced

3 Ansichten (letzte 30 Tage)
supernoob
supernoob am 13 Apr. 2018
Beantwortet: Guillaume am 13 Apr. 2018
Hi there, I'd like to find an efficient way of generating clusters of points where each cluster is periodically spaced. So for example, say for a given frequency f I want to generate a little cluster of points, starting at t=0, at each half period with some spread in time. So the periodic spacing of my points is the period/2. The cluster could be, say, 6 points which are spread by, say the period/20. So if my frequency was 1 Hz, T/2 = 0.5s. I want to generate some 'time points' starting at t=0 which would have 3 points spaced by 0.5s/10, then centered at T/2 6 points spread by 0.5s/10, then again at T, then again at 3/2T until I reach a specified maximum time. I can think of some fairly burdensome brute force approaches to this problem but something more elegant and efficient would be appreciated. Thanks!

Antworten (1)

Guillaume
Guillaume am 13 Apr. 2018
Generate your main period as a row vector, your cluster spread as a column vector of delta, add them and reshape into a vector and you're done:
mainperiod = 0.5;
clusterperiod = mainperiod / 20;
numpoints = 100;
halfclustercount = 3;
mainpoints = 0: mainperiod : mainperiod * (numpoints - 1);
clusterdelta = (-halfclustercount : halfclustercount) * clusterperiod;
fullvector = reshape(mainpoints + clusterdelta.', 1, [])

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by