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!