Memory overflown for the number to be saved
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Jan
2012 年 9 月 10 日
編集済み: Jan
2012 年 9 月 10 日
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 件)
Oleg Komarov
2012 年 9 月 10 日
編集済み: Oleg Komarov
2012 年 9 月 10 日
cs = regexp(A,'(?<=IMSI=)\d+','match');
str2double(cs{:})
5 件のコメント
Oleg Komarov
2012 年 9 月 10 日
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'.
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!