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
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?
ReturnToCastle
ReturnToCastle 2020년 5월 4일
It is 20log10(4πd/λ), where d represents the elements in the vector

댓글을 달려면 로그인하십시오.

 채택된 답변

James Tursa
James Tursa 2020년 5월 4일

0 개 추천

The log10( ) function is vectorized, so just this
result = 20 * log10(4*pi*d./lambda);

추가 답변 (1개)

David Hill
David Hill 2020년 5월 4일

0 개 추천

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
...

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2020년 5월 4일

댓글:

2020년 5월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by