Generate clusters of points which are periodically spaced
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (1)
Guillaume
el 13 de Abr. de 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, [])
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!