Very simple vectorization ?

1 次查看(过去 30 天)
Good afternoon !
Is it possible to vectorize this short code ?
hello(1)=0;
for i=2:10
hello(i)=hello(i-1)+1;
end
Because the next one is effectively unappropriate :
hello=zeros(1,10);
i=2:1:10;
hello(i)=hello(i-1)+1;
Thank you for your answers !

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-6-6
v = @(t1,dt,n)t1 + (0:n-1)*dt;
eg
v(0,1,10)
  3 个评论
Oleg Komarov
Oleg Komarov 2012-6-6
Just execute the two lines sequentially.

请先登录,再进行评论。

更多回答(1 个)

Sean de Wolski
Sean de Wolski 2012-6-6

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by