如何在MATLAB中正确设置数值积分?
我想整合这个表达式:
但是我似乎在设置功能时遇到了问题。正如本MATLAB解释中所述,我已经定义了一个名为'NDfx.m'的独立函数,如下所示:
function [ y ] = NDfx(x)
y = (1/sqrt(2*pi))*exp(-.5*x^2); % Error occurs here
end
但是当我在我的main函数中调用它时,我在上面的注释行中收到错误。我的主要功能如下:
function[P] = NormalDistro(u,o2,x)
delta = x-u;
dev = abs((delta)/o2); % Normalizes the parameters entered into function
P_inner = quad(@NDfx,-dev,dev); % Integrates function NDfx from -dev to dev (error here)
P_outer = 1 - P_inner; % Calculation of outer bounds of the integral
if delta > 0
P = P_inner + (P_outer/2);
elseif delta < 0
P = P_outer/2;
elseif dev == 0
P = .5;
end
end
我得到的具体错误是:
错误==> mpower
输入必须是标量和方阵
没有找到相关结果
已邀请:
2 个回复
绊伦欧
和
之类的运算符之前:
熊融炭臀陛