matlab批量载入数据

上传人:鲁** 文档编号:561269920 上传时间:2022-12-04 格式:DOC 页数:4 大小:30KB
返回 下载 相关 举报
matlab批量载入数据_第1页
第1页 / 共4页
matlab批量载入数据_第2页
第2页 / 共4页
matlab批量载入数据_第3页
第3页 / 共4页
matlab批量载入数据_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《matlab批量载入数据》由会员分享,可在线阅读,更多相关《matlab批量载入数据(4页珍藏版)》请在金锄头文库上搜索。

1、matlab批量载入数据.txt这是一个禁忌相继崩溃的时代,没人拦得着你,只有你自己拦着自己,你的禁忌越多成就就越少。自卑有多种档次,最高档次的自卑表现为吹嘘自己干什么都是天才。首先保证要处理的图像文件名为数字序列,例如photoT,photo-2,%Startname二zeros50000,20;%文件名矩阵numb二zeros50000,15;%需求数据矩阵fori=1:50000filename二strcat(filepath,photo-,int2str(i);%生成文件名name(i,:)二filename;%保存文件名I=imread(filename,jpg);%自编函数处理nu

2、mb(i,:)=a;%a为自编函数中返回的1*15矩阵,这个应该会吧dlmwrite(filename1.txt,name,delimiter,newline,pc);dlmwrite(filename2.txt,numb,delimiter,newline,pc);end+1)要读入的文件下的文件名称依序列的方式命名,如a1b.mat,a2b.mat,.,ajb.mat,.循环读入filepath二;文件夹的路径fori=1:n%nU要读入的文件的个数load(filepathanum2str(i)b.mat)end2)文件夹下的文件名称无规律如,文件夹里是n幅图皿.jpg)和一些数据(其他

3、类型),现在要读出所有的图像a,先得到文件路径di=dir(文件路径*.jpg);b,读入fork=1:length(di)I(k,:,:)=imread(件路径,di(k).name);end+主程序:clc;clear;fidin=fopen(title.txt,r);fidout=fopen(result.txt,w);继续whilefeof(fidin)%whilefeof表示若未读到文件末尾则循环wellname二fgetl(fidin);%如果没有使用fgetl函数,则feof判断没有作用,这将是一个死循环!titleline=strcat(wellname,.txt);efc_d

4、pt,efc_poro,efc_perm,efc_ratio=numprocessor(titleline);efc_rst=efc_dpt,efc_poro,efc_perm,efc_ratio;fprintf(fidout,wellname);%fprintf(fidout,%s%s%s%sn,efc_rst);fprintf(fidout,%8.1f%6.2f%6.2f%6.4fn,efc_rst);endfclose(fidin);fclose(fidout);部分文件名(title.txt)B12-B51-58B12-B53-58B12-B55-59B12-B55-62B12-B55

5、-64B12-B57-51B14-B50-44B14-B50-48B14-B51-46B14-B52-49B14-B54-48B14-B54-53B14-B54-74B14-B55-52B14-B55-56B14-B55-60B14-B55-63B14-B55-65B14-B55-67B14-B55-69B14-B55-75B14-B56-49B14-B56-53B14-B56-70functionefc_dpt,efc_poro,efc_perm,efc_ratio=numprocessor(file)%读入数据,进行处理,输出结果matdat=load(file);n,l=size(mat

6、dat);efc_dpt=0;efc_perm=0;efc_poro=0;efc_ratio=0;fori=1:n-1matdat(i,1)=matdat(i+1,1)-matdat(i,1);endfori=1:n-1ifmatdat(i,3)=1efc_dpt=efc_dpt+matdat(i,1);efc_perm=efc_perm+matdat(i,5)*matdat(i,1);efc_poro=efc_poro+matdat(i,4)*matdat(i,1);ifmatdat(i,2)=0efc_ratio=efc_ratio+matdat(i,1);endendendifefc_d

7、pt=0efc_perm=0;efc_poro=0;efc_ratio=0;elseefc_perm=efc_perm/efc_dpt;efc_poro=efc_poro/efc_dpt;efc_ratio=efc_ratio/efc_dpt;end井的数据1865.230001867.8 016.80.11874.430001885113.30.021888.8 30001891.8 012.30.03189730001898012.30.03190330001906.2012.30.03191130001914.6113.40.2119193000+多数据文件批处理的一个技巧数据处理过程中

8、,很多时候需要对大批的数据文件进行循环处理。如果文件名是有规律的,那么正常的方法尚可处理,但是碰到文件名没什么规律,或规律不强时,表示出这些文件按名就是一件很头疼的事了。假设现有以下文件需要进行循环处理,以供参考。1、MATLABclc;clear;%将e:/POP/data/下的文件信息写入构架数组file_strueturefile_structure=dir(e:/POP/data/);%file_strueture.name下是e:/POP/data/内的文件名fori=3:size(file_strueture)filename=streat(e:/POP/data/,file_strueture(i).name)%straet连接字符串f=netedf(filename,nowrite);a=在此对f及里面的变量操作.elose(f)endform=1:100load(mufuceshi,num2str(m),.mat)end

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号