I want to integrate this expression:

However, I seem to be having problems setting up the function. As indicated in this MATLAB explanation, I defined a separate function called "NDfx.m" that looks like this:
function [ y ] = NDfx(x) y = (1/sqrt(2*pi))*exp(-.5*x^2); % Error occurs here end
However, when I call it in my main function, I get an error message in the above line. My main function looks like this:
function[P] = NormalDistro(u,o2,x) delta = xu; 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
The specific error I get is:
Error in ==> mpower
Inputs must be scalar and square matrix
source share