fid1=fopen('Hk1.dat','a+');
for z=0:0.1:k;
f=z;
g=inline('cos(f*sin(x))');
[S,n]=quad(g,-pi,pi);
%J0=1/(2*pi)*S;
fprintf(fid1,'% f % f\n',f,S);
end
fclose(fid1)
出现的错误为:
??? Error using ==> inline.subsref
Not enough inputs to inline function.
Error in ==> quad at 62
y = f(x, varargin{:});
Error in ==> fhkl at 5
[S,n]=quad(g,-pi,pi);
我不明白到底第五行到底出现了啥错误,请求指点!
谢谢了
fid1=fopen('Hk1.dat','a+');
for z=0:0.1:k;
f=z;
g=inline('cos(f*sin(x))');
[S,n]=quad(g,-pi,pi);
%J0=1/(2*pi)*S;
fprintf(fid1,'% f % f\n',f,S);
end
fclose(fid1)
出现的错误 ...
doc quad
个人觉得好像不可以用inline,可以试试下面的代码:
fid1=fopen('Hk1.dat','a+');
z=0:0.1:2;
for i=1:length(z)
f=z(i);
g=@(x)cos(f*sin(x));
[S,n]=quad(g,-pi,pi);
%J0=1/(2*pi)*S;
fprintf(fid1,'% f % f\n',f,S);
end
fclose(fid1)