By using “vector(end:-1:1)” operation

The end keyword in MATLAB is used for  either finding a row or column index to reference the last element,

Example 1:

Matlab




% MATLAB code for find inverse
% of vector using end keyword
% Initializing a vector of some elements
v = [10;9;8;7;6;5]
 
% Reversing the above vector's elements
v(end:-1:1)


Output:

Example 2:

Matlab




% MATLAB code for find inverse
% of vector using end keyword
% Initializing a row vector
v = 10:20
 
% Reversing the above vector's elements
v(end:-1:1)


Output:
 



How to inverse a vector in MATLAB?

In this article, we are going to discuss the “Inversion of a vector” in MATLAB which can be done in three different approaches that are illustrated below:

Similar Reads

Method 1: By using flipud() function

The flipud() function is used for flipping the specified vector’s elements....

Method 2: By using fliplr() function

...

Method 3: By using “vector(end:-1:1)” operation

...