convert real numbers to img form

1 次查看(过去 30 天)
armin m
armin m 2021-11-26
hi.i have real number which i want to convert t img form. how can i do this?
e.g: 8 to 8i
tnx

回答(1 个)

Chunru
Chunru 2021-11-26
a = 8
a = 8
b = a*1i % method 1
b = 0.0000 + 8.0000i
c = complex(0, a) % method 2
c = 0.0000 + 8.0000i
  1 个评论
John D'Errico
John D'Errico 2021-11-26
编辑:John D'Errico 2021-11-26
+1 of course, as this seems to cover the bases completely.
I would only add that MATLAB does not have a purely imaginary form, only a complex form. Since the OP seems to be hoping to see a number of the form 8i, they may become confused when seeing a zero real part displayed. If the real part is zero, then the result is purely imaginary.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by