# How to extract the first four and last four digits of all numbers of an array where each number is of 12 digits?

31 Ansichten (letzte 30 Tage)
Abhishek Chakraborty am 24 Mär. 2021
I have an array of over 200,000 numbers. Each of these numbers is of 12 digits. I want to extract and form another array with: (1) the first four digits of the original array, (2) the last four digits of the original array. How can it be done?
For example if one of the numbers of the array is 123456789012, then the output to (1) should be "1234" and output to (2) should be "9012".
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Abhishek Chakraborty am 24 Mär. 2021
It is a numeric array. All the elements in the array are numbers.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

DGM am 24 Mär. 2021
Bearbeitet: DGM am 24 Mär. 2021
Try this
% this is my example data
num=[152012073637; ...
325081863583; ...
841721647389; ...
648968298758; ...
346301193257; ...
595880316669];
numtail=mod(num,1E4)
the results are:
1520
3250
8417
6489
3463
5958
numtail =
3637
3583
7389
8758
3257
6669
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Abhishek Chakraborty am 24 Mär. 2021
Thanks a lot

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Tables in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by