Matlab error using m power

so if i run this function in matlab

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

It works fine. now if i change it to take a square like this

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

it gives me an error, an error using ==> mpower the dimensions of the matrix must match. Why does this give me an error, I can make this element by element, but I have a lot of data and it will take a lot of time.

+3
source share
1 answer

It seems you want to make the element by the element that is. ^ 2 not ^ 2

That is, change to

sim1(row,1:512)= ((image(row,1:512,1)-a(1,1))).^2;
+6
source

Source: https://habr.com/ru/post/1731308/


All Articles