# how to separate the figures of specific number using matlab ?

1 Ansicht (letzte 30 Tage)
Kommentiert: mohammad am 14 Jun. 2014
How to separate the figures of specific number and then making a new vector which will include the figures that have been separated separately ?? for example : if i have a number as (123456789) , what is the function or command that will separate these figures of the number so that they look like this form 1 2 3 4 5 6 7 8 9 Meaning that will turn into a vector
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Image Analyst am 12 Jun. 2014
Try this:
n = 123456789;
% Convert to a string.
strn = num2str(n)
% Initialize with all spaces.
output = char(32*ones(1,2*length(strn)))
% Make every other character the digits from the number.
output(1:2:end) = strn
##### 3 Kommentare2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
i'm so sorry my friend , the mistake occurred ,your code is correct 100 percent . i have performed it in wrong way thank you very much.

Melden Sie sich an, um zu kommentieren.

Brian B am 13 Jun. 2014
Bearbeitet: Brian B am 13 Jun. 2014
Perhaps you want the characters converted back to numbers? If so, try
n=123456789
str =num2str(n)
strn = regexp(str,'\d','match')
str2double(strn)
##### 1 KommentarKeine anzeigenKeine ausblenden
thank you very much 'Brian'

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by