Extracting information from matrix using data from a vector

1 view (last 30 days)
I'm starting to realize that matlab may have been a bit much for my programming capabilities at this juncture. I'm close, just a few more questions.
I have a Vector R2 = [4;6] and I also have a large matrix K_structure. How do I extract values from the K_structure matrix corresponding with the values stored in vector R2? I'd like a new matrix K_small:
K_small(1,1) = K_structure(R2(1,1),R2(1,1))
K_small(1,2) = K_structure(R2(1,1),R2(2,1))
K_small(2,1) = K_structure(R2(2,1),R2(1,1))
K_small(2,2) = K_structure(R2(2,1),R2(2,1))
*Note R2 is not a fixed length and could be longer which would mean the K_small matrix would also grow, but always be square. i.e. if the length of R2 were 3 then the K_small matrix would then be 3x3.

Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!