select only one value every four (or different numbers) in an array

3 vues (au cours des 30 derniers jours)
SYML2nd
SYML2nd le 29 Nov 2021
Réponse apportée : Chunru le 29 Nov 2021
Hi,
I would like to select only one value every four in an array. For instance, given an array [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16], I obtain
[4 8 12 16]. Are there simple commands to do this?

Réponse acceptée

Chunru
Chunru le 29 Nov 2021
a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
a = 1×16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
b = a(4:4:16)
b = 1×4
4 8 12 16

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by