MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   While循环Matlab中的指令 (https://www.labfans.com/bbs/showthread.php?t=26754)

poster 2019-12-14 20:46

While循环Matlab中的指令
 
该指令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

[B]回答:[/B]

执行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 ]

[url=https://stackoverflow.com/questions/5495440]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:42

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.