From: Sofia Häggberg on
>>sum(( ([I( : ), J( : )] - repmat(x, y,1)) .^2) ,2)

x<1x2 double>
y<1x1 double>

I<1x200 double> Min:1 Max: 10
J<1x200 double> Min:1 Max: 10

what the square brackets or box brackets [ ] means in this case? Moreover, if you can please clarify all the sentence!

Thanks...
From: Jan Simon on
Dear Sofia!

> >>sum(( ([I( : ), J( : )] - repmat(x, y,1)) .^2) ,2)
>
> x<1x2 double>
> y<1x1 double>
>
> I<1x200 double> Min:1 Max: 10
> J<1x200 double> Min:1 Max: 10
>
> what the square brackets or box brackets [ ] means in this case? Moreover, if you can please clarify all the sentence!

I suggest to read the "Getting started" section of the documentation:
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html

I do not think it is efficient for you and for me and the newgroup, if somebody starts to explain SUM, brackets, the horizontal/vertical concatenation with [ and ], the (:) operation, minus, REPMAT and the elementwise power operator ".^".

Some help can be found also with:
help !
help paren

Kind regards, Jan
From: Matt Fig on
When I was first learning MATLAB, I would often encounter compact expressions like this. The technique I used to understand them, and one that I think you would do well to adopt, is to break it apart and just observe the parts.



N = 3; % This is 200 in your example, but is arbitrarily >0.

I = ceil(rand(1,N)*10) % min/max = 1,10
J = ceil(rand(1,N)*10) % min/max = 1,10
x = ceil(rand(1,2)*10) % min/max = 1,10
y = N
% Now break down the expression and look at its parts.
A = [I( : ), J( : )] % compare this to I,J
B = repmat(x, y,1) % compare this to x, then to A
C = (A - B) .^2
D = sum(C ,2) % See the help for the SUM function.
From: Sofia Häggberg on
Thank You, Matt Fig!!!

Regards to you Jan Simon.

Sofia

"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hissph$d95$1(a)fred.mathworks.com>...
> When I was first learning MATLAB, I would often encounter compact expressions like this. The technique I used to understand them, and one that I think you would do well to adopt, is to break it apart and just observe the parts.
>
>
>
> N = 3; % This is 200 in your example, but is arbitrarily >0.
>
> I = ceil(rand(1,N)*10) % min/max = 1,10
> J = ceil(rand(1,N)*10) % min/max = 1,10
> x = ceil(rand(1,2)*10) % min/max = 1,10
> y = N
> % Now break down the expression and look at its parts.
> A = [I( : ), J( : )] % compare this to I,J
> B = repmat(x, y,1) % compare this to x, then to A
> C = (A - B) .^2
> D = sum(C ,2) % See the help for the SUM function.