Extracting information from matrix using data from a vector

조회 수: 1 (최근 30일)
Mark . 2013년 3월 12일
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.

답변 (0개)


Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by