0
0
MATLABdata~5 mins

Matrix transpose in MATLAB

Choose your learning style9 modes available
Introduction

Matrix transpose flips a matrix over its diagonal. It swaps rows with columns.

When you want to switch rows and columns in a table of numbers.
To prepare data for certain math operations that need matching dimensions.
When you want to change the orientation of a matrix for easier reading or processing.
Syntax
MATLAB
B = A';

The apostrophe (') operator transposes matrix A and stores it in B.

For complex matrices, ' also takes the complex conjugate. Use dot-apostrophe (.' ) for transpose without conjugate.

Examples
Transpose a 2x3 matrix to get a 3x2 matrix.
MATLAB
A = [1 2 3; 4 5 6];
B = A';
Transpose a complex matrix; conjugate is applied.
MATLAB
C = [1+1i 2-1i; 3+0i 4+4i];
D = C';
Transpose without conjugate using dot-apostrophe.
MATLAB
E = C.';
Sample Program

This program creates a 2x3 matrix A, then transposes it to get B, which is 3x2. It prints both matrices.

MATLAB
A = [1 2 3; 4 5 6];
B = A';
disp('Original matrix A:');
disp(A);
disp('Transposed matrix B:');
disp(B);
OutputSuccess
Important Notes

Using ' on complex matrices also flips the sign of imaginary parts (complex conjugate).

Use dot-apostrophe (.' ) if you want to transpose without changing imaginary parts.

Transpose changes the shape: rows become columns and columns become rows.

Summary

Matrix transpose swaps rows and columns.

Use apostrophe (') for transpose in MATLAB.

For complex matrices, ' also conjugates; use dot-apostrophe (.' ) to avoid conjugation.