tags:

views:

73

answers:

1

so if I run this function in matlab

sim1(row,1:512)= ((image(row,1:512,1)-a(1,1)));

it runs fine. now if I modify it to take the square like this

sim1(row,1:512)= ((image(row,1:512,1)-a(1,1)))^2;

it gives me the error, error using ==> mpower matrix dimensions must agree. Why is this giving me the error, I can do this element by element but I have a lot of data and it will take forever.

+6  A: 

It seems you want to do an element by element power which is .^2 not ^2

That is, change to

sim1(row,1:512)= ((image(row,1:512,1)-a(1,1))).^2;
Ramashalanka
thanks man I didn't know about the dot operator in matlab
n0ob

related questions