How to expand a small matrix to a larger matrix

5 vues (au cours des 30 derniers jours)
J Lim
J Lim le 12 Mar 2021
Commenté : J Lim le 13 Mar 2021
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
David Hill le 12 Mar 2021
What are you inserting into the white squares? zeros, nan, or something else?
J Lim
J Lim le 12 Mar 2021
Zeros

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
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
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])
nodalNumber = 1×16
1 2 3 4 5 6 11 12 13 14 17 18 19 20 21 22
J Lim
J Lim le 13 Mar 2021
Thank you!! Yes this was what I was trying to do! Thanks for all the help!

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by