What does this instruction vector=[vector,sum(othervector)]
does in matlab inside a while loop like:
vector=[];
while a - b ~= 0
othervector = sum(something') %returns a vector
vector=[vector,sum(oth开发者_Go百科ervector)]; %it keeps a new vector?
...
end
vector=vector./100
Executing a = [a,b]
means append b
to a
, thus vector
will eventually be a matrix where each column is the row-wise sum of something'
.
More concretely: suppose something'
is this matrix:
something' = [ 1, 2; 3, 4 ];
Then sum(something')
is:
othervector = [ 3 ; 7 ]
And initially vector
is empty, so this sets vector
to
vector = [ 3 ; 7 ]
Suppose we repeat with a new something'
consisting of
[ 5, 5; 5, 6 ]
Then sum(something')
is:
othervector = [ 10; 11 ]
And now we augment this to vector
using vector = [vector, sum(othervector)]
:
vector = [ vector, [10; 11] ] = [ 3, 10 ; 7, 11 ]
精彩评论