Clear Filters
Clear Filters

i am stuck in this problem ive been trying all day and dont know from where to start. could you please help

2 views (last 30 days)
  2 Comments
Steven Lord
Steven Lord on 8 Apr 2024
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

Answers (1)

Neelanshu
Neelanshu on 15 Apr 2024
Hi Zahida,
As Steven mentioned, the question appears to be a homework assignment. Additionally, I couldn't find the "trap" function in the documentation.
I am providing you with some hints to get started on the problem. To solve the equations mentioned, you can refer to the mathematical expressions for the Simpson's and Trapezoidal rules as shown below:
Simpson's 1/3 rule
Simpson's 3/8 rule =
Trapezoidal rule =
Here is an example for the trapezoidal rule :
% Trapezoidal rule
a = -2; b = 4;
f = @(x) 1-x-4*x^3+2*x^5;
trap = (b-a)/2*(f(a)+f(b))
You have to use multiple segment versions of the above mentioned rules for the parts c and e. For the analytical solution, you may refer the following documentation to learn more about function "int" :
Hope this helps.
  1 Comment
John D'Errico
John D'Errico on 15 Apr 2024
+1. It is so rare that I find a good example of someone looking to help guide a student in their assignment, instead of just doing it for them. This is a great example of someone offering guidance. Thank you. A nudge in the right direction is a good thing.
I would comment that there is indeed no function named trap in MATLAB. It might be something the user would choose to write though, as one way to implement the trapezoidal integration. So it could evaluate one panel of the trapezoidal rule. Then just call it 2 or 4 times, depending on how many panels would be needed.
And that would in turn suggest the possible use of a loop, to generate those multiple panels needed for the multi-point parts of this question (thus part c for the question.)

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!