How to expand a small matrix to a larger matrix
6 views (last 30 days)
Show older comments
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 Comments
David Hill
on 12 Mar 2021
What are you inserting into the white squares? zeros, nan, or something else?
Accepted Answer
Cris LaPierre
on 12 Mar 2021
Edited: Cris LaPierre
on 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 Comments
Cris LaPierre
on 13 Mar 2021
Edited: Cris LaPierre
on 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])
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!