How to define a sequence that goes two directions

1 vue (au cours des 30 derniers jours)
Abid Manzar
Abid Manzar le 15 Sep 2021
Commenté : Abid Manzar le 16 Sep 2021
I have to write a Program that, among other things, defines a matrix and asks me to, in one line, assign the values, 12 6 0 -6 -12 12 18 24 30 36, to one row. I was thinking I should use the "x:1:y" type of command but I don't know how to make it go two directions in one command.

Réponse acceptée

Adam Danz
Adam Danz le 15 Sep 2021
[12:-6:-12, 12:6:36]
ans = 1×10
12 6 0 -6 -12 12 18 24 30 36
  3 commentaires
Adam Danz
Adam Danz le 16 Sep 2021
I've been using Matlab for more than 10 years and I still find things I didn't know Matlab could do. That's the fun part of this forum 😊.
Abid Manzar
Abid Manzar le 16 Sep 2021
For sure! I only started learning Matlab this semester and everything is new to me.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by