How to expand a small matrix to a larger matrix
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I am having a difficult time trying to figure out a loop that will expand the matrix on the left to the one on the right. Any help for this would be very appreciated!
Thank you

2 commentaires
David Hill
le 12 Mar 2021
What are you inserting into the white squares? zeros, nan, or something else?
Réponse acceptée
Cris LaPierre
le 12 Mar 2021
Modifié(e) : Cris LaPierre
le 12 Mar 2021
I think you need two for loops. One for the rows, one for the columns.
If you replace your current numbering with just integers, that might make it a little more obvious.
1x -> 1
1y -> 2
2x -> 3
...
6x -> 11
6y -> 12
7 commentaires
Cris LaPierre
le 13 Mar 2021
Modifié(e) : Cris LaPierre
le 13 Mar 2021
Probably. Exactly what is your starting point?
From your original code, something like this should work.
nodalNumber = [1 2 3 6 7 9 10 11];
nodalNumber = sort([2*nodalNumber 2*nodalNumber-1])
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
