找回密码
 注册
Simdroid-非首页
查看: 65|回复: 3

请教IQ数据读取

[复制链接]
发表于 2012-3-30 11:21:02 | 显示全部楼层 |阅读模式 来自 瑞典
各位,请教下我如何把下面复数的 实部 以及 虚部读出来。文件格式是 TXT的。关键是有括号。

(-0.000180407462116275,0.000492159127137877)       
(-0.00122151685652765,0.001184197905281)       
(-0.00300778084028639,0.000903791220769367)       
(-0.00413201265514443,4.01334237745417e-05)       
(-0.00341703423069789,0.000817812813551274)       
(-0.00166158559396808,0.00521171628514296)       
(-0.00112808034984909,0.0124133642164781)       
(-0.00282970020552435,0.0185826672202836)       
(-0.00468711630355861,0.0196213904802638)       
发表于 2012-3-30 20:53:52 | 显示全部楼层 来自 天津
Simdroid开发平台
一行一行的读取,用strfind函数定位括号,用sscanf函数读取数据,自己研究一下吧。

评分

1

查看全部评分

回复 不支持

使用道具 举报

 楼主| 发表于 2012-3-31 12:23:48 | 显示全部楼层 来自 瑞典
谢谢,已经解决了,可以正则表达式或者其他处理方法。

fid=fopen('waveform.txt');
data_iq=fscanf(fid,'%s');
index1 = findstr(data_iq,'(');
index2 = findstr(data_iq,',');
index3 = findstr(data_iq,')');
data_real = zeros(length(index1),1);
data_imag = zeros(length(index1),1);
IQ_data=zeros(length(index1),1);
format long e                  
for i = 1:length(index1)
data_real(i,1) = str2num(data_iq(index1(i)+1:index2(i)-1));
data_imag(i,1) = str2num(data_iq(index2(i)+1:index3(i)-1));
IQ_data(i)=data_real(i,1) +j.*data_imag(i,1);
end
回复 不支持

使用道具 举报

发表于 2012-3-31 12:39:18 | 显示全部楼层 来自 天津
blackbutter 发表于 2012-3-31 12:23
谢谢,已经解决了,可以正则表达式或者其他处理方法。

fid=fopen('waveform.txt');

未来版本中会移除findstr函数,用strfind函数替代。
Note:   findstr will be removed in a future release. Use strfind instead.
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-7-5 20:27 , Processed in 0.032798 second(s), 15 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表