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 件)
Image Analyst
2020 年 3 月 16 日
Try this:
n = 1 : 100
v2 = cos(n * pi / 8)
n = 1 : 30
v3 = n .* exp(n/10)
0 件のコメント
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!