开发者

Instruction inside a While Loop Matlab

开发者 https://www.devze.com 2023-02-21 03:27 出处:网络
What does this instruction vector=[vector,sum(othervector)] does in matlab inside a while loop like: vector=[];

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 ]
0

精彩评论

暂无评论...
验证码 换一张
取 消