matlab simpson求积问题首先建立了fun.mfunction y=fun(x)a=15575; c=972.5; y=62300*sqrt(1-(c/a)^2*sin(x)^2)然后运行quad(‘fun’,0,pi/2)显示quad(‘fun’,0,pi/2)|Error:Missing variable or function.
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/04 05:45:41
![matlab simpson求积问题首先建立了fun.mfunction y=fun(x)a=15575; c=972.5; y=62300*sqrt(1-(c/a)^2*sin(x)^2)然后运行quad(‘fun’,0,pi/2)显示quad(‘fun’,0,pi/2)|Error:Missing variable or function.](/uploads/image/z/5584719-39-9.jpg?t=matlab+simpson%E6%B1%82%E7%A7%AF%E9%97%AE%E9%A2%98%E9%A6%96%E5%85%88%E5%BB%BA%E7%AB%8B%E4%BA%86fun.mfunction+y%3Dfun%28x%29a%3D15575%3B+c%3D972.5%3B+y%3D62300%2Asqrt%281-%28c%2Fa%29%5E2%2Asin%28x%29%5E2%29%E7%84%B6%E5%90%8E%E8%BF%90%E8%A1%8Cquad%28%E2%80%98fun%E2%80%99%2C0%2Cpi%2F2%29%E6%98%BE%E7%A4%BAquad%28%E2%80%98fun%E2%80%99%2C0%2Cpi%2F2%29%7CError%3AMissing+variable+or+function.)
matlab simpson求积问题首先建立了fun.mfunction y=fun(x)a=15575; c=972.5; y=62300*sqrt(1-(c/a)^2*sin(x)^2)然后运行quad(‘fun’,0,pi/2)显示quad(‘fun’,0,pi/2)|Error:Missing variable or function.
matlab simpson求积问题
首先建立了fun.m
function y=fun(x)
a=15575; c=972.5;
y=62300*sqrt(1-(c/a)^2*sin(x)^2)
然后运行quad(‘fun’,0,pi/2)
显示
quad(‘fun’,0,pi/2)
|
Error:Missing variable or function.
matlab simpson求积问题首先建立了fun.mfunction y=fun(x)a=15575; c=972.5; y=62300*sqrt(1-(c/a)^2*sin(x)^2)然后运行quad(‘fun’,0,pi/2)显示quad(‘fun’,0,pi/2)|Error:Missing variable or function.
两处错误:
1、fun.m错,正确的应是:
function y=fun(x)
a=15575; c=972.5;
y=62300*sqrt(1-(c/a)^2*sin(x).^2);
%说明:quad要求输入函数能够处理向量,意思就是fun(x)当x是一个向量是也成立.所以函数中sin(x)后面是点运算 .^2.
2、quad 调用格式不对,quad的输入是函数句柄,而非字符串,应该如下
>> quad(@fun,0,pi/2)
ans =
97765