Memory overflown for the number to be saved

1 visualización (últimos 30 días)
Avinash bachu
Avinash bachu el 10 de Sept. de 2012
Hi
I have string like this.
A={'IMSI=208016702935545 CI=20796 LAC=29188'};
I have done this
imsi=regexp(A,'\w*IMSI=\w*','match');
After doing that I get
imsi{1,1}= 'IMSI=208016702935545';
Again I do this to extract the numbe out of it
cellinfo=sscanf(char(imsi{1,1}),'%*5c%d');
But the length of IMSI is too long and is overflown. can anyone suggest something so that I can have cellinfo=208016702935545 ;
Thanks in advance
Avinash
  4 comentarios
Oleg Komarov
Oleg Komarov el 10 de Sept. de 2012
Do not double post.
Then what is CI? How do you get it?
Avinash bachu
Avinash bachu el 10 de Sept. de 2012
Sorry, my mistake.
I corrected the question now. Actually, there is no CI. CI was the name given in my code.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 10 de Sept. de 2012
Editada: Jan el 10 de Sept. de 2012
A = {'IMSI=208016702935545 CI=20796 LAC=29188'};
num = sscanf(A{1}, 'IMSI=%g', 1);
This should actually work, because the 15 digits of the number should be covered by the double precision. Alternatively import it as UINT64:
num = sscanf(A{1}, 'IMSI=%lu', 1);
Obviously the "%d" format saturates at the INT32 limits.
  1 comentario
Avinash bachu
Avinash bachu el 10 de Sept. de 2012
Thanks Jan.
Importing to uint64 didnt work. it was saturated at uint32 using %lu.
Thanks anyway

Iniciar sesión para comentar.

Más respuestas (1)

Oleg Komarov
Oleg Komarov el 10 de Sept. de 2012
Editada: Oleg Komarov el 10 de Sept. de 2012
Using the look-behind operator in regular expressions without capturing the token:
cs = regexp(A,'(?<=IMSI=)\d+','match');
str2double(cs{:})
  5 comentarios
Avinash bachu
Avinash bachu el 10 de Sept. de 2012
Thanks Oleg. I tried cs = regexp(A,'(?<=IMSI=)\g+','match'); which didnt work. Do you have any other way around. i am very bad at matlab syntax.
Oleg Komarov
Oleg Komarov el 10 de Sept. de 2012
The '\d+' part in the regexp() does not relate to the sscanf() syntax.
cs = regexp(A,'(?<=IMSI=)\d+','match')
The line identifies characters belonging to the set '1234567890'.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by