Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

complex number matlab

Status
Not open for further replies.

aliazmat

Banned
Joined
Mar 14, 2008
Messages
76
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Activity points
0
Hi all,

when we have some complex number like

a=0.1250 - 3.1230i and when we run command in matlab

a>=0

the result will be 1. I want to ask that how does matlab evaluates it because if we take magnitude of it by

abs(a) this comes 3.1255

so how to decide that the given complex number is great than or equal to 0?
 

complex numbers matlab

matlab syntax is similar like C language.
if you want to compare the value of a, you would write if a>==0
 

matlab if statement with complex numbers

The correct syntax is "a>=0" without the double "==".
In the numerical comparison, the real part is taken.
Regards

Z
 

    aliazmat

    Points: 2
    Helpful Answer Positive Rating
test for a complex number matlab

U mean that if a complex number is compared with "0" it means it is compared with only real part and imaginary part does not have any role in that

for example

0.03+9i >= 0 , answer will be 1
-0.03+9i >= 0 , answer will be 0
0.03-9i >= 0 , answer will be 1
-0.03-9i >= 0 , answer will be 0


am I right ?
 

complex and matlab

Yes, you are, aliazmat.

From Matlab help:

The relational operators are <, >, <=, >=, ==, and ~=. Relational operators perform element-by-element comparisons between two arrays. They return a logical array of the same size, with elements set to true (1) where the relation is true, and elements set to false (0) where it is not. The operators <, >, <=, and >= use only the real part of their operands for the comparison. The operators == and ~= test real and imaginary parts.

Regards

Z
 
  • Like
Reactions: tzehei

    aliazmat

    Points: 2
    Helpful Answer Positive Rating

    tzehei

    Points: 2
    Helpful Answer Positive Rating
matlab syntax complex

1 means ur statment is true
 

    aliazmat

    Points: 2
    Helpful Answer Positive Rating
testing for imaginary numbers matlab

thank you very very much for your help .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top