checking and generating fix length value
Mostra commenti meno recenti
i have coed which gives result by summing all the numbers but i need the sum must be of length of 4 numbers
example i add 16 different numbers and sum = 834
i need this 834 in 0843 form???
2 Commenti
Stephen23
il 19 Dic 2014
Are you converting the numeric to string or displaying the numbers somehow?
The numeric formats used to store numbers on computers don't (usually) distinguish between 0834 and 834, so the question does not really make sense unless you are converting the number to a string or displaying it in some other way. Please edit your question to indicate what exactly what you are trying to achieve.
Raza
il 19 Dic 2014
Risposta accettata
Più risposte (1)
Azzi Abdelmalek
il 19 Dic 2014
a=83
b=num2str(a)
out=[repmat('0',1,4-numel(b)) b]
1 Commento
Raza
il 19 Dic 2014
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!