首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Matlab 读资料

2012-10-06 
Matlab 读文件%格式化读fid fopen(abc.txt,r)A fscanf(fid,%d)fclose(fid)%当只有一列s的时候

Matlab 读文件

%格式化读fid = fopen('abc.txt','r');A = fscanf(fid,'%d')fclose(fid)%当只有一列s的时候直接用load函数 当只有一行的时候直接用facanf%当有多列多行的时候 用textscanf读取格式化文本文件fid = fopen('abc.txt','r');%返回原包数据 A[1] A[2]%A = textscan(fid,'%d %d')[A B] = textscan(fid,'%d %d')%[A B] = textread('abc.txt','%d %d')%文件指针ftell(fid)fclose(fid)%忽略文本文件的某些行fid = fopen('abc.txt','r');A = textscan(fid,'%d %d','HeaderLines',1)fclose(fid)%读取一个字符串的内容str = 'This is 1 2 3 4.3 5 6.4';strdata = textscan(str,'%c')%strdata{:}'%读取前八个字符[strdata,pos] = textscan(str,'%8c',1)[intdata,pos] = textscan(str(pos+1:pos+6),'%5c',1)

热点排行