Effacer les filtres
Effacer les filtres

Create a specific matrix (MATLAB)

2 vues (au cours des 30 derniers jours)
high speed
high speed le 6 Mar 2022
Commenté : Star Strider le 6 Mar 2022
Dear members
I want create a square matrix in such a way that I got the general form:
For example if we have m=4, we got:
How can I program that please!

Réponse acceptée

Star Strider
Star Strider le 6 Mar 2022
Try this —
M = hankel(1:4,4:-1:1)
M = 4×4
1 2 3 4 2 3 4 3 3 4 3 2 4 3 2 1
.
  2 commentaires
high speed
high speed le 6 Mar 2022
@Star Strider Thank you! That's what I need
Star Strider
Star Strider le 6 Mar 2022
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

DGM
DGM le 6 Mar 2022
This is one way:
A = flipud(toeplitz([4 3 2 1]))
A = 4×4
1 2 3 4 2 3 4 3 3 4 3 2 4 3 2 1

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by