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)

FAQs

How to create a complex array in MATLAB? ›

Description. z = complex( a , b ) creates a complex output, z , from two real inputs, such that z = a + bi . z = complex( x ) returns the complex equivalent of x , such that isreal(z) returns logical 0 ( false ). If x is real, then z is x + 0i .

How to create a complex variable in MATLAB? ›

Restrictions When Defining Complex Variables

Assign a complex constant to the variable or use the complex function. For example: x = 5 + 6i; % x is a complex number by assignment. y = complex(5,6); % y is the complex number 5 + 6i.

How to create a complex matrix? ›

If at least one element of a matrix is a complex number + , where a, b are real andi = √−1, then the matrix is called a complex matrix. The matrix obtained by replacing he elements of a complex matrix A by the corresponding conjugate complex number is called the conjugate of the matrix A and is denoted by ̅.

How do you create an array of structures in MATLAB? ›

To create an array of structures using the struct function, specify the field value arguments as cell arrays. Each cell array element is the value of the field in the corresponding structure array element. For code generation, corresponding fields in the structures must have the same type.

How do you create a multidimensional array? ›

Array-Basics in Java Multidimensional Arrays can be defined in simple words as array of arrays. Data in multidimensional arrays are stored in tabular form (in row major order). Syntax: data_type[1st dimension][2nd dimension][]..[Nth dimension] array_name = new data_type[size1][size2]….[sizeN];

What is a complex array? ›

A complex array is a data storage term that refers to an array of disks that support data structures in more complex ways than a simple RAID array. Rather than just allowing for multi-disk storage, a complex array can really micro-manage the use of multiple disks to create optimal data transfer and storage solutions.

How to do complex integration in MATLAB? ›

In MATLAB®, you use the 'Waypoints' option to define a sequence of straight line paths from the first limit of integration to the first waypoint, from the first waypoint to the second, and so forth, and finally from the last waypoint to the second limit of integration.

How do you generate a complex random number in MATLAB? ›

X = randn(___,"like", p ) returns an array of random numbers like p ; that is, of the same data type and complexity (real or complex) as p . You can specify either typename or "like" , but not both. X = randn( s ,___) generates numbers from random number stream s instead of the default global stream.

How do you express complex in MATLAB? ›

In MATLAB®, i and j represent the basic imaginary unit. You can use them to create complex numbers such as 2i+5 . You can also determine the real and imaginary parts of complex numbers and compute other common values such as phase and angle.

How to plot a complex matrix in Matlab? ›

Plot Array of Complex Numbers

You can also use plot(z,LineSpec) instead of plot(real(z),imag(z),LineSpec) to plot an array of complex numbers. This function automatically plots the real part in the x -axis and the imaginary part in the y -axis.

How to write a complex equation in Matlab? ›

Direct link to this answer
  1. z = 1 + 3*1i ; % make a complex number.
  2. R = real(z) % Extract real part of Z.
  3. I = imag(z) % Extract imaginary part of Z.
  4. A = abs(z) ; % GEt absolute of complex number.
Dec 3, 2017

How do you create a dynamic matrix? ›

Create a Dynamic Matrix
  1. Go to SETUP > Checklist Setup Process.
  2. Select the checklist.
  3. Select “Checkpoint” from the Process Menu.
  4. Click the blue “+Add” button to insert a new checkpoint row.
  5. In the Checkpoint Type column, select "Dynamic Matrix." There are several types of dynamic matrix checkpoint type to choose from.
May 13, 2024

How do I create a custom array in MATLAB? ›

To create an array with multiple elements in a single row, separate the elements with either a comma ',' or a space. This type of array is called a row vector. To create an array with multiple elements in a single column, separate the elements with semicolons ';'. This type of array is called a column vector.

How do you create a nested cell array in MATLAB? ›

Building Nested Arrays with Nested Curly Braces

You can nest pairs of curly braces to create a nested cell array. For example, clear A A(1,1) = {magic(5)}; A(1,2) = {{[5 2 8; 7 3 0; 6 7 3] 'Test 1'; [2-4i 5+7i] {17 []}}} A = [5x5 double] {2x2 cell}

What is the difference between array and cell array in MATLAB? ›

A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. A cell array is a data type with indexed data containers called cells, where each cell can contain any type of data.

How to write a complex equation in MATLAB? ›

Direct link to this answer
  1. z = 1 + 3*1i ; % make a complex number.
  2. R = real(z) % Extract real part of Z.
  3. I = imag(z) % Extract imaginary part of Z.
  4. A = abs(z) ; % GEt absolute of complex number.
Dec 3, 2017

How do you create an infinite array in MATLAB? ›

To create an infinite array, use the infiniteArray object to repeat a single antenna element (unit cell), infinitely along the X-Y plane. The layout function displays a typical unit cell.

How to create a 3-D array? ›

To create a three-dimensional array in Python, we pass an object representing x by y by z, where x represents the nested lists, y represents the nested lists inside the x nested lists, and z represents the values inside each y nested list.

Top Articles
Kaptain Kush on LinkedIn: Maegan Hall Biography: Age, Net Worth, Spouse, Height, Wiki, Parents…
18 Appleton Circle, Fitchburg, MA, Massachusetts, property flyer
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
R/Skinwalker
Rugged Gentleman Barber Shop Martinsburg Wv
Jennifer Lenzini Leaving Ktiv
Justified - Streams, Episodenguide und News zur Serie
Epay. Medstarhealth.org
Olde Kegg Bar & Grill Portage Menu
Cubilabras
Half Inning In Which The Home Team Bats Crossword
Amazing Lash Bay Colony
Juego Friv Poki
Dirt Devil Ud70181 Parts Diagram
Truist Bank Open Saturday
Water Leaks in Your Car When It Rains? Common Causes & Fixes
What’s Closing at Disney World? A Complete Guide
New from Simply So Good - Cherry Apricot Slab Pie
Drys Pharmacy
Ohio State Football Wiki
Find Words Containing Specific Letters | WordFinder®
FirstLight Power to Acquire Leading Canadian Renewable Operator and Developer Hydromega Services Inc. - FirstLight
Webmail.unt.edu
2024-25 ITH Season Preview: USC Trojans
Metro By T Mobile Sign In
Restored Republic December 1 2022
Lincoln Financial Field Section 110
Free Stuff Craigslist Roanoke Va
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 5821

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.