我有这样的代码在R:用于MatLab的R等效中的Mod()函数?
> test <- c(1+1i,2+2i,3+3i,4+4i,5+5i)
> test
[1] 1+1i 2+2i 3+3i 4+4i 5+5i
> Mod(test)
[1] 1.414214 2.828427 4.242641 5.656854 7.071068
我无法找到针对R MOD()函数的取代。我尝试了MatLab中的real()函数,但删除了虚构的组件(不想要我想要的)。
>> test = [1+1*i, 2+2*i, 3+3*i, 4+4*i, 5+5*i]
test =
1.0000 + 1.0000i 2.0000 + 2.0000i 3.0000 + 3.0000i 4.0000 + 4.0000i 5.0000 + 5.0000i
>> real(test)
ans =
1 2 3 4 5
from https://uk.mathworks.com/help/matlab/ref/abs.html?requestedDomain=www.mathworks.com,sectrion *复数的大小*,可能是''' – user20650