How to expand a small matrix to a larger matrix

6 views (last 30 days)
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

Accepted Answer

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

Sign in to comment.

More Answers (0)

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!