Memory overflown for the number to be saved

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

Oleg Komarov
Oleg Komarov 2012년 9월 10일
Where do you get the error?
Also, how do you create A?
Avinash bachu
Avinash bachu 2012년 9월 10일
Hi Oleg The A is input data from the servers. cant change it.
When I do the sscanf to extract the IMSI from the A; I get cellinfo as
2147483647,00000 and it is same for different IMSI number.
instead of 208016702935545
Oleg Komarov
Oleg Komarov 2012년 9월 10일
Do not double post.
Then what is CI? How do you get it?
Avinash bachu
Avinash bachu 2012년 9월 10일
Sorry, my mistake.
I corrected the question now. Actually, there is no CI. CI was the name given in my code.

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2012년 9월 10일
편집: Jan 2012년 9월 10일

0 개 추천

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

Avinash bachu
Avinash bachu 2012년 9월 10일
Thanks Jan.
Importing to uint64 didnt work. it was saturated at uint32 using %lu.
Thanks anyway

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Oleg Komarov
Oleg Komarov 2012년 9월 10일
편집: Oleg Komarov 2012년 9월 10일

0 개 추천

Using the look-behind operator in regular expressions without capturing the token:
cs = regexp(A,'(?<=IMSI=)\d+','match');
str2double(cs{:})

댓글 수: 5

Avinash bachu
Avinash bachu 2012년 9월 10일
Hi Oleg,
Using the look-behind operator I am able to extract cs without capturing the token.
But the memory problem hasnt been solved yet. the IMSI number is too big to be converted into double, it just gives NAN as output. I wonder how i can convert it into uint64. Check it once
Thanks again
Jan
Jan 2012년 9월 10일
편집: Jan 2012년 9월 10일
@Avinash, have you seen my answer? %d overflows atthe INT32 limits, but %g imports to a double directly.
Oleg Komarov
Oleg Komarov 2012년 9월 10일
@Avinash: I did not encounter the problem with your example. Do you have longer numbers?
Avinash bachu
Avinash bachu 2012년 9월 10일
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.
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'.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2012년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by