By using flipud() function
The flipud() function is used for flipping the specified vector’s elements.
Syntax:
flipud(A)
Here, flipud(A) function is used to return a vector with reversed elements of the same length of the specified vector “A”.
Example 1:
Matlab
% MATLAB code for inverse a % vector using flipud() % Initializing a vector of some elements v = [10;9;8;7;6;5] % Calling the flipud() function % over the above vector "v" to % reverse its elements flipud(v) |
Output:
Example 2:
Matlab
% MATLAB code for inverse vector using flip() % Initializing a 2*2 cell array of characters A = { 'a' 'b' ; 'c' 'd' } % Calling the flipud() function % over the above cell array to % reverse its elements flipud(A) |
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: