How to use flip( ) and sprintf() In MATLAB
The sprintf() function is used to format the data into a string or character vector.
Syntax: sprintf(formatSpec, A1, …, An)
Here, sprintf(formatSpec, A1, …, An) is used to format the data in arrays A1,…, An uses the formatting operators specified by formatSpec and returns the resulting text in str.
Example:
Matlab
% MATLAB code for reverse a number % using flip() and sprintf() % Calling the flip() function over the % sprintf() function with number % 5678 as its parameter to reverse Reversed_Number = flip(sprintf( '%d' , 5678), 2) |
Output:
Reversed_Number = 8765
How to reverse a number in MATLAB?
In this article, we will discuss the “Reversing of a number” in MATLAB that can be done using the multiple methods which are illustrated below.