| 查看: 334 | 回复: 2 | |||
jacketdanster金虫 (小有名气)
|
[交流]
【求助】函数使用问题 已有2人参与
|
|
原来在6.0下面可以运行的函数,装了7.0a以后运行不了,请帮忙分析一下,谢谢 提示出错如下: ??? Error using ==> fopen Invalid filename. Error in ==> pretreatment at 6 fid=fopen([pname fname],'r'); 我运行的函数如下: clc,clear format short e % Open a File and Import Original Data. [fname,pname]=uigetfile('*.txt','Open a file:'); fid=fopen([pname fname],'r'); fgetl(fid);% Here 'fgetl' command is used to jump to read next line. fgetl(fid); fgetl(fid); a=fscanf(fid,'%f',[7 inf]); fclose(fid); a1=a'; Dtime=a1(:,1);Ddtg=a1(:,2);Dtg=a1(:,3);Ddhf=a1(:,4);Dhf=a1(:,5);Ddt=a1(:,6);Dt=a1(:,7); %hl1=line(Dt,Dtg,'color','k'); %ax1=gca; %set(ax1,'Xcolor','k','ycolor','k') %ax2=axes('position',get(ax1,'Position'), ... % 'XAxisLocation','top',... % 'YAxisLocation','right',... % 'Color','none',... % 'XColor','b','YColor','b'); %hl2=line(Dt,Ddtg,'Color','b','Parent',ax2); %grid on; [haxes,hline1,hline2]=plotyy(Dt,Dtg,Dt,Ddtg);grid on; xlabel('Temperature ( ^oC )') axes(haxes(1)) ylabel('Thermogravimetry (%)') axes(haxes(2)) ylabel('DTG (d%)') % Select the Temperature Range for Calculation prompt={'Enter the Initial Temperature /C:','Enter the Final Temperature /C:'}; def={'20','200'}; num_line=1; answer=inputdlg(prompt,'Please Input the Temperature Range for Calculate!',num_line,def); T(1)=str2num([answer{1}]); T(2)=str2num([answer{2}]); r=1; while Dt(r) end rs=r; while Dt(r) end re=r-1; Dalfa=(Dtg(rs:re)-Dtg(rs))/-13.73;%%%%%%%%% Dt=Dt(rs:re)+273.15; Dtime=Dtime(rs:re); Ddt=Ddt(rs:re); Ddalfa=Ddtg(rs:re)/-13.73; % Program for interpolation and calculate Ddtg & Ddt rn=1; for i=0.10:0.02:0.75 %%%%%% Dalfa1(rn,1)=i; r=1; ri=0; rf=0; n=size(Dalfa,1); while Dalfa(r) r=r+1; end rt=r; if rt<12 ri=1; rf=rt+11; elseif rt>n-11 ri=rt-12; rf=n; else ri=rt-12; rf=rt+11; end % calculate for interpolation of temperature %p=polyfit(Dt(ri:rf),Dalfa(ri:rf),2) p=[Dt(ri:rf).^2 Dt(ri:rf) ones(rf-ri+1,1)]\Dalfa(ri:rf); %p1=polyval(p,Dt(ri:rf)); p(3)=p(3)-Dalfa1(rn,1); DtI=roots(p); if abs(DtI(1)-Dt(rt))<=abs(DtI(2)-Dt(rt))%DtI(1)>=Dt(rt-2) & DtI(1)<=Dt(rt+1) Dt_new(rn,1)=DtI(1); else Dt_new(rn,1)=DtI(2); end % Calculate the differential temperature pat=[Dtime(ri:rf).^2 Dtime(ri:rf) ones(rf-ri+1,1)]\Dalfa(ri:rf); pat(3)=pat(3)-Dalfa1(rn,1); DtimeI=roots(pat); if abs(DtimeI(1)-Dtime(rt))<=abs(DtimeI(2)-Dtime(rt)) Dtime_new(rn,1)=DtimeI(1); else Dtime_new(rn,1)=DtimeI(2); end Ddtg_new(rn,1)=(2*pat(1)*Dtime_new(rn,1)+pat(2))*60; % calculate for interpolation of time pt=[Dtime(ri:rf).^2 Dtime(ri:rf) ones(rf-ri+1,1)]\Ddt(ri:rf); % Calculate the differential temperature Ddt_new(rn,1)=polyval(pt,Dtime_new(rn,1)); %Ddt_new(rn,1)=(2*pt(1)*Dtime_new(rn,1)+pt(2))*60; rn=rn+1; rt=0; end % Export the Result c=[Dalfa1 Dt_new Ddtg_new Ddt_new]; [filename,pathname]=uiputfile('*.txt','Save the Result File Name'); fid=fopen([pathname filename],'wt'); fprintf(fid,'Temperature Range: %6.2f - %6.2f C\n',T); fprintf(fid,' alfa T(K) dalfa/dt(min-1) Rate\n'); fprintf(fid,'%5.4f %8.4f %8.6f %8.4f\n',c'); fclose(fid); clf figure(1) plot(Dt,Dalfa,Dt_new,Dalfa1,'o',Dt,Ddalfa,Dt_new,Ddtg_new,'^') |
» 猜你喜欢
疑惑?
已经有5人回复
国自然申请面上模板最新2026版出了吗?
已经有14人回复
计算机、0854电子信息(085401-058412)调剂
已经有5人回复
基金委咋了?2026年的指南还没有出来?
已经有3人回复
Materials Today Chemistry审稿周期
已经有5人回复
溴的反应液脱色
已经有7人回复
推荐一本书
已经有12人回复
基金申报
已经有4人回复
纳米粒子粒径的测量
已经有7人回复
常年博士招收(双一流,工科)
已经有4人回复
» 本主题相关价值贴推荐,对您同样有帮助:
关于 scanf 函数的问题
已经有4人回复
用matlab画一个函数,能帮我看看程序哪里有问题吗
已经有8人回复
matlan求解含有三角函数的隐函数问题?
已经有15人回复
matlab求函数积分出错
已经有12人回复
线性规划linprog函数的使用问题
已经有10人回复
visual里面定义函数出错
已经有4人回复
MATLAB-pdepe函数使用问题
已经有5人回复
类成员函数调用的问题
已经有3人回复
单片机C语言编程中的自定义函数使用问题
已经有4人回复
怎么找出lapack函数及函数的使用方法
已经有8人回复
关于得到分子波函数的问题
已经有12人回复
NumPy包的函数使用问题
已经有7人回复
scanf()函数中读入字符串问题
已经有4人回复
用matlab绘制含参隐函数的问题
已经有8人回复
opencv cvFindContours函数的一些问题
已经有8人回复
matlab的函数调用问题
已经有3人回复
问个关于matlab里find函数的问题!
已经有4人回复
matlab 求解隐式常微分方程时用ode15i 函数出现的问题求助
已经有3人回复
关于LANL2DZ加极化函数的问题
已经有15人回复
【讨论】关于一个m文件中函数调用及画图问题
已经有7人回复
【求助】用graythresh函数遇到的问题
已经有8人回复
【求助】求积分程序中被积函数问题
已经有15人回复
【求助】Mittag-leffler函数问题
已经有3人回复

2楼2010-04-23 14:52:30
jacketdanster
金虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 1046.6
- 帖子: 173
- 在线: 147.2小时
- 虫号: 341704
- 注册: 2007-04-08
- 性别: GG
- 专业: 热力学
3楼2010-04-23 15:42:10











回复此楼