How to reverse a number?

9 views (last 30 days)
Jessica
Jessica on 18 Nov 2014
Edited: Guillaume on 18 Nov 2014
Hi,
I want to reverse a number without using MATLAB functions "digitrevorder()" and "fliplr()". Please help. Thank you!

Answers (2)

Evan
Evan on 18 Nov 2014
x = 1234;
s = num2str(x) - '0';
xr = polyval(s(end:-1:1),10)
  7 Comments
Guillaume
Guillaume on 18 Nov 2014
You also want to disallow rot90, flipud and flip, otherwise it's also trivial.

Sign in to comment.


Syed Haider
Syed Haider on 18 Nov 2014
A = [1 2 3 4; 5 6 7 8];
y = A(:,end:-1:1)
  3 Comments
John D'Errico
John D'Errico on 18 Nov 2014
I don't see any reason to remove it.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by