How to best find whether or not a matrix is made of evenly spaced elements.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Aaron Atkinson
le 21 Avr 2020
Réponse apportée : Star Strider
le 21 Avr 2020
I am currently writing an algorithem and I need to be able to tell whether or not an input matrix is made up of evenly spaced elements, so far i've tried to use the diff function but I haven't been able to integrate the results of that into an algorithem.
0 commentaires
Réponse acceptée
Star Strider
le 21 Avr 2020
I would use:
dm = diff(M,[],dim);
dmean = mean(dm);
dstd = std(dm);
where ‘M’ is your matrix, to initially assess them.
For evenly-spaced elements,‘dstd’ should be on hte order of 1E-15 or less, although that has to be taken in the context of the value of ‘dmean’, which is the reason for calculating it. If you want to be certain the elements are evenly-spaced in the appropriate dimension, use the Signal Processing Toolbox resample function to resample them to a constant sampling interval.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!