views:

112

answers:

1

Hi, I'm a bit new to MATLAB.

Basically, I have a 20x20 values , complete with various random entries ranging from 0 to 3. I need to write a program that reads this 20x20 square, and assigns x-y coordinates to the entries, so that when I ask for an input of a particular x-y coordinate which has, say an entry of 3, then it will result in an error. I'm a bit overwhelmed - but I understand the general concept of what I'm supposed to be finding. I'm wondering if I should use a plot instead to help me.

+6  A: 

If you need all the x and y coordinates where there is a 3, you could use find:

[x,y] = find(m == 3)

for a matrix named 'm'.

There's more on find in matlab's documentation.

daniel

related questions