Simple question: How to set the complex part = 0 in an array?

3 ビュー (過去 30 日間)
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 8 月 31 日
コメント済み: Sam Chak 2022 年 8 月 31 日
Hi! I have this 1x5 matrix whicihcontains complex numbers -
2+0i; 3+3i; 5+0i; 8-4i; 6+9i;
How can I set "only" the complex numbers = 0 so that I only have the real part of thisn matrix? I want this -
2; 3; 5; 8; 6;
Thank you!!

採用された回答

Sam Chak
Sam Chak 2022 年 8 月 31 日
How about like this?
a = [2+0i; 3+3i; 5+0i; 8-4i; 6+9i]
a =
2.0000 + 0.0000i 3.0000 + 3.0000i 5.0000 + 0.0000i 8.0000 - 4.0000i 6.0000 + 9.0000i
b = real(a)
b = 5×1
2 3 5 8 6
  2 件のコメント
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 8 月 31 日
ugghh damn it, it was so easy lol. Thank you so much btw.
Sam Chak
Sam Chak 2022 年 8 月 31 日
You are welcome, @Ashfaq Ahmed. Have a nice day!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by