How to use polyval( ) and num2str( ) In MATLAB
The polyval(p, x) function is used to return the value of a polynomial of degree n evaluated at x. The input argument p is a vector of length n+1 whose elements are the coefficients in descending powers of the polynomial to be evaluated.
Syntax: polyval(p, x)
Parameters: This function accepts two parameters,
- p: This is the specified input vector of length n+1.
- x: This is the specified matrix or vector or array.
Matlab
% MATLAB code for polyval() for reverse a number % Specifying a number to reverse Number = 3579 % Calling the num2str() over the % above number s = num2str(Number) - '0' ; % Calling the polyval() function Reversed_Number = polyval(s( end :-1:1),10) |
Output:
Number = 3579 Reversed_Number = 9753
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.