Performing calculations on a vector
14 ビュー (過去 30 日間)
古いコメントを表示
I have a vector of (50,1) I need to apply a formula and perform calculations on each element in the vector how do I achieve this?
2 件のコメント
James Tursa
2020 年 5 月 4 日
Depends on the formula and whether the functions involved are vectorized or not. You may have to write a loop. What is your formula?
採用された回答
James Tursa
2020 年 5 月 4 日
The log10( ) function is vectorized, so just this
result = 20 * log10(4*pi*d./lambda);
その他の回答 (1 件)
David Hill
2020 年 5 月 4 日
Using elementwise functions and operators.
v.^2;
v.*m;%v and m same size
v./m;%v and m same size
v.^m;%va and m same size
...
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!