Hi all,
Imagine there is a m by m matrix, I'd like to extract the [p, q] element, while [p, q] is the output of some calculations. For instance:
K>> a = rand(3)a = 0.88517 0.098712 0.67973 0.91329 0.26187 0.13655 0.79618 0.33536 0.72123K>> b = [2 3]b = 2 3K>> a(b)ans = 0.91329 0.79618
Here b is the location, which should be the 2nd row, 3rd column. However, here Matlab gives the 2nd and 3rd element by column indexing. What I want is 0.13655.
I know I can use:
K>> a(b(1), b(2))ans = 0.13655
But this is manual, my matrix may have random dimension, so I prefer something like a(b), any ideas?
Best Answer