real part of a complex number

3 次查看(过去 30 天)
JazzMusic
JazzMusic 2017-3-6
编辑: Stephen23 2017-3-6
Hi,
I am trying to get the real part of a complex number and my matlab gives error.
for example: I write:
Z = 2+3*i;
X = real(Z) code
and I get:
Index exceeds matrix dimensions.
Any idea why?

回答(1 个)

Stephen23
Stephen23 2017-3-6
编辑:Stephen23 2017-3-6
Because you have assigned the name real to a variable. When you shadow an inbuilt function or variable with your own variable, then that inbuilt function cannot be called.
Solution: clear that variable:
clear real
And do not use variable names length, size, cell, i, j, real, etc.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by