MATLAB: Plotting a two dimensional equation with an integral

functionintegrationMATLABplotting

Hi!
I would like to plot the function
For different values of K. How do I do this?
Thanks in advance

Best Answer

Something like this
K = 1:10; % or whatever values you want
for i = 1:numel(K)
I(i) = integral(@(theta) Ifn(theta,K(i)),-pi/2,pi/2);
end
plot(K,I),grid
function kern = Ifn(theta,K)
r = 2; % replace with true value
kern = cos(theta).^2.*exp(-(K*r*sin(theta)).^2/2)/(2*pi);
end