-
2 Comments
Pasumarthi Viswanath
on 11 Nov 2012
please explain why the digits get separated when (num2str(2^n)-'0') is performed
Cris Luengo
on 12 Nov 2012
num2str converts the integer number into a string representation of that number: 1234 becomes '1234', which is the same as ['1','2','3','4']. Now you've got one array entry per digit. Subtract '0' from there, then the char array will become a double array with value 0 where the char was '0', etc.
Suggested Problems
-
6682 Solvers
-
Make a random, non-repeating vector.
10216 Solvers
-
How long is the longest prime diagonal?
400 Solvers
-
581 Solvers
-
526 Solvers
More from this Author96
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!