integration in matlab
时间:04-01
整理:3721RD
点击:
Matlab is giving error in integration of expression like {sin(x)/cosh(x)},how to do it?
Here is some simple code. If you are using this for a school project or something, I would recommend using trapezoidal rule or something more sophisticated. Anyway, this code performs the integration and does not get an error on my computer.
% Define Integration Parameters
N = 1000;
x1 = -10;
x2 = 10;
% Compute Function
x = linspace(x1,x2,N);
f = sin(x)./cosh(x);
% Compute Integral
dx = (x2-x1)/N;
fi = sum(f)*dx;
% Show Results
plot(x,f);
disp(['Integral from x1 to x2 is ' num2str(fi)]);
Hi,thanks for the reply..........but I have solved this problem through Numerical methods by approximating function
give the expression like this
(sin(x)/cosh(x));
How about searching mfun?