![]() |
Matlab中的for循环
如何在循环中获取向量的每个索引,这是将向量的值传递给函数
vector =[ 20 , 30 , 60 ,45 ,26 ,17 ,28,9, 10,3 ] n = 10 for i=1:n somefunt( vector(i) ); end 所以这是翻译 somefunt( vector(20) ); somefunt( vector(30) ); somefunt( vector(60) ); ... 这该怎么做? [B]回答:[/B] 如果要在vector [URL="http://www.mathworks.com/help/techdoc/ref/for.html"]循环[/URL]中将vector所有值传递给函数somefunt ,则可以将vector用作循环值,如下所示: for i = vector somefunt(i); end 这等效于: somefunt(20); somefunt(30); somefunt(60); ... [url=https://stackoverflow.com/questions/5467264]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 23:21。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.