Create complex array - MATLAB complex (2024)

Create complex array

collapse all in page

Syntax

z = complex(a,b)

z = complex(x)

Description

example

z = complex(a,b) createsa complex output, z, from two real inputs, suchthat z = a + bi.

The complex function provides a useful substitutefor expressions, such as a + 1i*b or a+ 1j*b, when

  • a and b arenot double or single

  • b is all zeros

example

z = complex(x) returnsthe complex equivalent of x, such that isreal(z) returnslogical 0 (false).

  • If x is real, then z is x+ 0i.

  • If x is complex, then z isidentical to x.

Examples

collapse all

Complex Scalar from Two Real Scalars

Open Live Script

Use the complex function to create the complex scalar, 3 + 4i.

z = 3.0000 + 4.0000i

Complex Vector from Two Real Vectors

Open Live Script

Create a complex uint8 vector from two real uint8 vectors. The size of z, 4-by-1, is the same as the size of the input arguments.

a = uint8([1;2;3;4]);b = uint8([2;2;7;7]);z = complex(a,b)
z = 4x1 uint8 column vector 1 + 2i 2 + 2i 3 + 7i 4 + 7i

Complex Scalar from One Real Scalar

Open Live Script

Create a complex scalar with zero imaginary part.

z = complex(12)
z = 12.0000 + 0.0000i

Verify that z is complex.

isreal(z)
ans = logical 0

Input Arguments

collapse all

aReal component
scalar | vector | matrix | multidimensional array

Real component, specified as a scalar, vector, matrix, or multidimensionalarray.

The size of a must match the size of b,unless one is a scalar. If either a or b isa scalar, MATLAB® expands the scalar to match the size of theother input.

a and b can have different data types. However, if either a or b is an integer data type, then the other input must have the same integer type or be a full (not sparse) scalar double.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

bImaginary component
scalar | vector | matrix | multidimensional array

Imaginary component, specified as a scalar, vector, matrix,or multidimensional array.

The size of b must match the size of a,unless one is a scalar. If either a or b isa scalar, MATLAB expands the scalar to match the size of theother input.

a and b can have different data types. However, if either a or b is an integer data type, then the other input must have the same integer type or be a full (not sparse) scalar double.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

xInput array
scalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensionalarray.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical
Complex Number Support: Yes

Output Arguments

collapse all

z — Complex array
scalar | vector | matrix | multidimensional array

Complex array, returned as a scalar, vector, matrix, or multidimensionalarray.

The size of z is the same as the input arguments.

The following describes the data type of z when a and b have different data types.

  • If either a or b is single, then z is single.

  • If either a or b is logical, then z is the data type of the nonlogical input.

  • If either a or b is an integer data type, then z is the same integer data type.

Additionally, z is only sparse when both input arguments a and b are sparse.

Tips

  • If b contains only zeros, then z iscomplex and the value of all its imaginary components is 0.In contrast, the addition a + 0i returns a strictlyreal result.

Extended Capabilities

This function fully supports tall arrays. Formore information, see Tall Arrays.

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

See Also

abs | angle | conj | i | imag | isreal | j | real

Topics

  • Create Complex Numbers

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Create complex array - MATLAB complex (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Create complex array - MATLAB complex (2024)
Top Articles
Qidreh (Palestinian Spiced Lamb and Rice Recipe)
Easy Kenyan Beef Pilau Rice Recipe · eat well abi
Chatiw.ib
Junk Cars For Sale Craigslist
Amtrust Bank Cd Rates
Ross Dress For Less Hiring Near Me
Beacon Schnider
Southside Grill Schuylkill Haven Pa
Chalupp's Pizza Taos Menu
Caroline Cps.powerschool.com
Teamexpress Login
Large storage units
What’s the Difference Between Cash Flow and Profit?
Spelunking The Den Wow
Ap Chem Unit 8 Progress Check Mcq
Little Rock Arkansas Craigslist
Ukraine-Russia war: Latest updates
Morocco Forum Tripadvisor
Uhcs Patient Wallet
Flights To Frankfort Kentucky
Panorama Charter Portal
Suffix With Pent Crossword Clue
Best Forensic Pathology Careers + Salary Outlook | HealthGrad
Farmer's Almanac 2 Month Free Forecast
All Obituaries | Buie's Funeral Home | Raeford NC funeral home and cremation
Heart and Vascular Clinic in Monticello - North Memorial Health
Ups Drop Off Newton Ks
Free Personals Like Craigslist Nh
Www.paystubportal.com/7-11 Login
Happy Homebodies Breakup
Play Tetris Mind Bender
Jcp Meevo Com
Craiglist.nj
Urban Dictionary Fov
Kimoriiii Fansly
Urbfsdreamgirl
4 Methods to Fix “Vortex Mods Cannot Be Deployed” Issue - MiniTool Partition Wizard
Hrconnect Kp Login
Sf Bay Area Craigslist Com
Craigslist Free Puppy
Ixlggusd
Gyeon Jahee
Crazy Balls 3D Racing . Online Games . BrightestGames.com
Fetus Munchers 1 & 2
Noaa Duluth Mn
Gasoline Prices At Sam's Club
Home Auctions - Real Estate Auctions
Login
Sechrest Davis Funeral Home High Point Nc
Best Suv In 2010
SF bay area cars & trucks "chevrolet 50" - craigslist
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated:

Views: 6191

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.