声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1603|回复: 2

matlab中文本读入

[复制链接]
发表于 2005-4-23 18:16 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
<P>发信人: zjliu (秋天的萝卜), 信区: Matlab<BR>标  题: 文本读入 from bbs.matwav.com<BR>发信站: BBS 哈工大紫丁香站 (Fri Apr 22 13:41:40 2005)</P>
<P><a href="http://bbs.matwav.com/index.jsp?url=http%3A//bbs.matwav.com/post/view%3Fbid%3D" target="_blank" >http://bbs.matwav.com/index.jsp?url=http%3A//bbs.matwav.com/post/view%3Fbid%3D</A><BR>12%26id%3D142474%26sty%3D1%26tpg%3D1%26age%3D30</P>
<P>自己的一点经验,希望触类旁通。<BR>%example of data format;<BR>%Date (Day of year) Time foF2 foEs h'F peak F2<BR>%2000.04.03 (094) 00:01:05 13.850 230.2 314.1 319.0<BR>%2000.04.03 (094) 00:01:05 13.850 --- 314.1 319.0<BR>...<BR>%2000.04.03 (094) 00:01:05 13.850 230.2 314.1 319.0</P>
<P>function [iYD,UT,foF2,hmF2]=ReadData<BR>Year=[]; iYD=[]; UT=[]; foF2=[]; hmF2=[]; dhmF2dt=[];N=0;<BR>%Choose file and open file;<BR>[Fname,fpath]=uigetfile('*.*','the file for Scaled Ionospheric Parameters');<BR>fname=lower([fpath Fname]);<BR>fIN=fopen(fname,'r');<BR>if fIN==-1<BR>WarnStr=['Cannot open file: !' fpath fname];<BR>else<BR>%<BR>%Read data;<BR>Line=fgetl(fIN);<BR>MaxLength=length(deblank(Line));<BR>foF2Loc=findstr(Line,'foF2')+3;<BR>if length(foF2Loc)==0, uiwait(warndlg('no foF2 dat')); break; end;<BR>hmF2Loc=findstr(Line,'peak F2')+6;<BR>if length(hmF2Loc)==0,uiwait(warndlg('no hmF2 dat')); break; end;<BR>%read data;<BR>count=0;<BR>while ~feof(fIN)<BR>Line=fgetl(fIN);<BR>if length(Line)&gt;=25<BR>DOY=str2num(Line(13:15));<BR>count=count+1;<BR>% Year;<BR>year=str2num(Line(1:4));<BR>Year=[Year,year];<BR>% Julian day;<BR>iYD=[iYD DOY];<BR>% UT in h;<BR>time=str2num(Line(18:19)) +str2num(Line(21:22))/60 +str2num(Line(24:25))/3600;</P>
<P>UT=[UT time];<BR>%foF2;<BR>t=Line(foF2Loc-2:foF2Loc);<BR>if t=='---',<BR>foF2=[foF2 NaN];<BR>else,<BR>t=str2num(Line(foF2Loc-8:foF2Loc));<BR>foF2=[foF2 t];<BR>end;<BR>%hmF2;<BR>t=Line(hmF2Loc-2:hmF2Loc);<BR>if t=='---',<BR>hmF2=[hmF2 NaN];<BR>else,<BR>t=str2num(Line(hmF2Loc-8:hmF2Loc));<BR>hmF2=[hmF2 t];<BR>end;<BR>end;<BR>end;<BR>fclose(fIN);<BR>end</P>
回复
分享到:

使用道具 举报

发表于 2005-6-29 10:49 | 显示全部楼层
hao
发表于 2006-5-18 18:54 | 显示全部楼层

xiexie

xiewxie la
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-20 11:52 , Processed in 0.061152 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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