|
Hi,
I know that for a Vector A: A'*A creates a Matrix of all the elements of A multiplied by each other.
Is there a similar method for adding/subtracting, without looping?
I guess you have to turn the Vector into a repeated matrix, and then find the sum/difference.
Thus far i have:
>> a = [1 2 3 4 5]
a =
1 2 3 4 5
>> b = a'*ones(1,length(a))
b =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
>> c = ones(1,length(a))'*a
c =
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
>> c-b
ans =
0 1 2 3 4
-1 0 1 2 3
-2 -1 0 1 2
-3 -2 -1 0 1
-4 -3 -2 -1 0
Is there a better / less verbose method?
Zeph
|