what this equation means 4*L/(2*i-1)?

조회 수: 2 (최근 30일)
BA
BA 2023년 11월 22일
댓글: Alexander 2023년 11월 22일
I am trying to convert this equation 4*L/(2*i-1) into R
I failed to undersatnd why the output is two negative values in matlab
but R'output is a single value
L= 17;
i=4;
(2*i-1) gives -1 + 2; Is it i here is a complex number?
  댓글 수: 3
Torsten
Torsten 2023년 11월 22일
편집: Torsten 2023년 11월 22일
If you use the expression 4*L/(2*i-1) in R, I guess that "i" was set to a value somewhere before in the R-code. If you set "i" to the same value in your MATLB code, MATLAB will compute the same value for the expression as R does. If you don't set "i" to a value before you compute the expression, MATLAB will interprete "i" as the imaginary unit.
L = 17;
i = 4;
4*L/(2*i-1)
ans = 9.7143
clear i
4*L/(2*i-1)
ans = -13.6000 -27.2000i
Alexander
Alexander 2023년 11월 22일
Never use i or j if you are not dealing with complex numbers. Use ii or jj instead if you have to.

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

채택된 답변

ScottB
ScottB 2023년 11월 22일
Yes, Matlab sees "i" as complex. Maybe pick another variable if you are just using scalars.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by