I'm trying to integrate the following function but without any luck

I'm trying to integrate the following function but without any luck
f(x)= ((A)/(2*pi))* atan( B*x^3+ C*x^2 +D *x)
I would also like to plot the results from x=[-3:3]
I'm a new user to Matlab. Could you please help?
Your help is greatly appreciated.

 Accepted Answer

First, define some x range over which to plot the function and integrate. Someone (your instructor?) has said the range should be from -3 to 3. You could simply use x = -3:3;, but then you'd only have seven points. Use smaller steps for higher resolution, e.g., x = -3:.1:3 if you want dx to equal 1/10.
Then define your function, call it y or fx or whatever you'd like. Your instructor has given you the function to integrate, so start by plotting the function so you can visualize it:
y = (A/(2*pi))*...
plot(x,y)
To integrate, think about what integration is. It's a sum over small steps. For a first attempt you could make a loop, and add up the parts of y for every little step. Then after you've gotten the right answer that way, you can look for more computationally-efficient ways to perform the integration.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Asked:

on 11 Nov 2014

Answered:

on 11 Nov 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!