登录论坛

查看完整版本 : While循环Matlab中的指令


poster
2019-12-14, 20:46
该指令vector=[vector,sum(othervector)]在while循环内的matlab中做什么:

vector=[]; while a - b ~= 0 othervector = sum(something') %returns a vector vector=[vector,sum(othervector)]; %it keeps a new vector? ... end vector=vector./100

回答:

执行a = [a,b]意味着将b附加到a ,因此vector最终将是一个矩阵,其中每一列都是something'的行式和。

更具体地讲:假设something'是此矩阵:

something' = [ 1, 2; 3, 4 ]; 那么sum(something')是:

othervector = [ 3 ; 7 ] 最初的vector为空,因此将vector设置为

vector = [ 3 ; 7 ] 假设我们重复一个新的something'包括

[ 5, 5; 5, 6 ] 那么sum(something')是:

othervector = [ 10; 11 ] 现在我们使用vector = [vector, sum(othervector)]扩充为vector :

vector = [ vector, [10; 11] ] = [ 3, 10 ; 7, 11 ]

更多&回答... (https://stackoverflow.com/questions/5495440)