Is it possible to do this without a loop
9 次查看(过去 30 天)
显示 更早的评论
Is it possible to create a vector like this without a loop?

I have only managed v2 with a loop that goes like this:
for k=1:100
v2(k)=cos(k*pi/8)
end
0 个评论
回答(2 个)
Arthur Roué
2020-3-16
编辑:Arthur Roué
2020-3-16
% The cos function operates element-wise on arrays
v2 = cos((1:100)*pi/8);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!