1 visualizzazione (ultimi 30 giorni)
I have a matrix similar to the following
C = 1 2 4 5
3 4 5 6
6 4 2 1
each of these values have been calculated as a function of x and y. Say
x = a b c d
y = f g h
This corresponds to x as so
C = 1(f, a) 2(f, b) 4(f, c) 5(f, d)
3(g, a) 4(g, b) 5(g, c) 6(g, d)
6(h, a) 4(h, b) 2(h, c) 1(h, d)
Say I want to get the corresponding x and y values for a value in C, how would I do this?
David Young il 24 Nov 2011
As Jan comments, your question is not clear. Like him, I can't understand the role of the symbols a, b etc. which just seem to correspond to the subscripts for the matrix, with a=1, b=2, c=3, d=4, f=1, g=2, h=3. If so, they are redundant, and it's simpler to use numerical subscripts.
Guessing a bit, perhaps your question is simply asking what the subscripts are for a particular value in C. So C(3) is at x=1, y=2. If that's right, the answer is this:
[y, x] = find(C == 3)
which returns the x and y coordinates for the value 3. Note the reversal in order of y and x in the results list. If you use 6 rather than 3 you will get vectors for x and y each with 2 subscripts, because 6 is found at x=4,y=2 and also at x=1,y=3.
If you were asking something more complex, please clarify.