如何在Matlab中消除向量中的复数 [英] how to eliminate complex number in a vector in Matlab
本文介绍了如何在Matlab中消除向量中的复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Matlab中,假设有一个向量,其元素可以是复杂的或真实的.我想知道如何删除非真实元素,从而减小向量的大小?谢谢和问候!
In Matlab, suppose there is a vector whose elements can be complex or real. I was wondering how to remove the nonreal elements, and consequently reduce the size of the vector? Thanks and regards!
推荐答案
>> x = [1+i; 4+3i; 5+6i]
x =
1 + 1i
4 + 3i
5 + 6i
>> real(x)
ans =
1
4
5
>> imag(x)
ans =
1
3
6
编辑
以上内容未回答发布者的问题.这样.
The above doesn't answer the poster's question. This does.