- 积分
- 67
- 注册时间
- 2002-6-14
- 仿真币
-
- 最后登录
- 1970-1-1
|
发表于 2002-8-12 22:06:54
|
显示全部楼层
来自 北京
Re:【求助】好几个问题!谢谢
关于uiputfile的用法,我这里有一个文件可以参考一下。uiputfile的作用是以界面的方式提供保存文件的路径和文件名。可以参考Matlab本身的帮助文件。help uiputfile。
至于保存参数,可以用任何格式保存,完全由自己定义。我认为,可以用txt文件,也可以直接用SAVE命令保存为*.mat格式,关键是保存和读取方便。这也可以参照这个文件。
function flag=write_env_txt(header,data);
%write a envi ascii file,header is the header information in the file
%data is the actual data of the file
%the whole file include two parts: header and data, is saved as ASCII file.
%written by Xiaohong,Lv, 5/22 2002,
%Email-address: chenjialv@163.net, Xidian University
%all rights be reserved by Xiaohong, Lv
flag=-1;
sz=size(header);
header=header';
temp=header(:)';
if findstr(temp,'ENVI')==[]
error('this is not a ENVI file');
end
tempdir=pwd;
[filename,pathname]=uiputfile({'*.txt','ENVI ASCII file'},'Input the filename *.txt');
cd (pathname);
fid=fopen(filename,'w');
if fid==-1
error('cannot open the file');
end
row=sz(1);
col=sz(2);
for i=1:row
fprintf(fid,'%s',header(:,i));
fprintf(fid,'\n');
end
sz=size(data);
row=sz(1);
col=sz(2);
for i=1:512
for j=1:512
fprintf(fid,'%-14.4f',data(i,j));
end
if i~=512
fprintf(fid,'\n');
end
end
flag=1;
fclose(fid);
cd (tempdir); |
|