matlab quad积分问题function y=JF(x,Ua,a,b)y=Ua*a/(pi*(a^2+(b-x)^2));end 执行quad(@(x)JF(x,75,50,200),0,400);后报错:? Error using ==> mpowerMatrix must be square.Error in ==> JF at 2y=Ua*a/(pi*(a^2+(b-x)^2));Error in ==> @(x)JF(x,75,50,200)
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/06 07:41:49
matlab quad积分问题function y=JF(x,Ua,a,b)y=Ua*a/(pi*(a^2+(b-x)^2));end 执行quad(@(x)JF(x,75,50,200),0,400);后报错:? Error using ==> mpowerMatrix must be square.Error in ==> JF at 2y=Ua*a/(pi*(a^2+(b-x)^2));Error in ==> @(x)JF(x,75,50,200)
matlab quad积分问题
function y=JF(x,Ua,a,b)
y=Ua*a/(pi*(a^2+(b-x)^2));
end
执行quad(@(x)JF(x,75,50,200),0,400);后报错:
? Error using ==> mpower
Matrix must be square.
Error in ==> JF at 2
y=Ua*a/(pi*(a^2+(b-x)^2));
Error in ==> @(x)JF(x,75,50,200)
Error in ==> quad at 77
y = f(x, varargin{:});
求高手指点
matlab quad积分问题function y=JF(x,Ua,a,b)y=Ua*a/(pi*(a^2+(b-x)^2));end 执行quad(@(x)JF(x,75,50,200),0,400);后报错:? Error using ==> mpowerMatrix must be square.Error in ==> JF at 2y=Ua*a/(pi*(a^2+(b-x)^2));Error in ==> @(x)JF(x,75,50,200)
报错提示输入要求是矩阵,所以函数JF要支持矩阵输入输出,修改的程序如下:
JF.m
function y=JF(x,Ua,a,b)
y=Ua*a./(pi*(a^2+(b-x).^2)); %注意这行程序加了两个点
return
其他的不变,执行结果:
quad(@(x)JF(x,75,50,200),0,400)
ans = 63.3031