Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matrix dimensioin must agree

Subject: Matrix dimensioin must agree

From: anant naishadham

Date: 16 Jun, 2011 04:14:05

Message: 1 of 2

hi,
i'm trying to find cluster centers in an image.
when i go to a new pixel. i try to check if that pixel is a cluster center by checking all the pixels around it . if it is not and then i just flag the pixel as one that i've already visited in the image.
my problem is that when i try to check a certain pixel wether it has already been visited by the following statement:
if(any(tt(1:k,1)==position_pixel(t,1))==1)
      if(any(tt(1:k,2)==position_pixel(t,2))==1)

position_pixel gives the present pixel that is under consideration:
t is a counter that gives the row vector position
column vector 1 stores x position of the pixel where as column vector 2 stores the y vector position.

'tt' stores all the pixels that have already been visited.
column vector 1 and 2 of the 'tt' array also store the x aand y pixel postions respectively
k gives the number of rows of the 'tt' that have been written with the pixel values since i have previously declared 'tt' as 'tt=zeros(1000,2);'


while doing so i'm getting an error as follows:
??? Error using ==> eq
Matrix dimensions must agree.

while i just compare one element of the t array with all the elements of the 'tt ' array.. i'm not able to understand how this problem can be solved. help!

Subject: Matrix dimensioin must agree

From: Krishna Kumar

Date: 16 Jun, 2011 05:18:02

Message: 2 of 2

"anant naishadham" wrote in message <itbvud$48f$1@newscl01ah.mathworks.com>...
> hi,
> i'm trying to find cluster centers in an image.
> when i go to a new pixel. i try to check if that pixel is a cluster center by checking all the pixels around it . if it is not and then i just flag the pixel as one that i've already visited in the image.
> my problem is that when i try to check a certain pixel wether it has already been visited by the following statement:
> if(any(tt(1:k,1)==position_pixel(t,1))==1)
> if(any(tt(1:k,2)==position_pixel(t,2))==1)
>
> position_pixel gives the present pixel that is under consideration:
> t is a counter that gives the row vector position
> column vector 1 stores x position of the pixel where as column vector 2 stores the y vector position.
>
> 'tt' stores all the pixels that have already been visited.
> column vector 1 and 2 of the 'tt' array also store the x aand y pixel postions respectively
> k gives the number of rows of the 'tt' that have been written with the pixel values since i have previously declared 'tt' as 'tt=zeros(1000,2);'
>
>
> while doing so i'm getting an error as follows:
> ??? Error using ==> eq
> Matrix dimensions must agree.
>
> while i just compare one element of the t array with all the elements of the 'tt ' array.. i'm not able to understand how this problem can be solved. help!
Hi,
   Check if the k or t are scalars. Perhaps some mistake in the code could have made them into vectors, i that case, you would be getting this error.
hth
Krishna

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us