I need to compute an integral of a function that consist in the product between a Cumulative distribution of a Normal, and another term.
I tried using the command int, but in that case I was not able to execute the normcdf command.
Matlab said: CNaux2=normcdf(aux5) Error using NaN Trailing string input must be 'single' or 'double'.
Instead, i tried using the quad command. In that case, the normcdf could be defined as a function handle, but then i coul not excute the quad command. In this case matlab said
Error using * Inner matrix dimensions must agree.
And i don´t understand why, because i don´t have any matrix here, i have only a product of functions of one variable.
Could you please help me?
No products are associated with this question.
You didn't really explain what you tried. Here's an example that works:
If I use matrix multiplication "*" instead of elementwise multiplication ".*" I get the same error you report. So if your integrand is something like this, maybe you need to switch to elementwise multiplication.
I am no sure about the error you get, but try this version :
m=0; s=1; x=0:0.1:10; C=normcdf(x,m,s); PHI=2*exp(j*2*pi*x); % Consider it as wave function N=abs(PHI).^2; % consider it as the probability of existence . b=exp(-(x-2).^2);; % the thrid function as you consider II=C.*b.*N; figure, plot(x,II); F=trapz(x,II);
So the integral is evaluated using the function "trapz" along the X axis ,
I hope this helps
Play games and win prizes!Learn more