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

2 ビュー (過去 30 日間)
  2 件のコメント
Steven Lord
Steven Lord 2024 年 4 月 8 日
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.
Zahida
Zahida 2024 年 4 月 8 日
this is a tutorial sheet i started out by doing the following code below but dont know if its correct

サインインしてコメントする。

回答 (1 件)

nick
nick 2024 年 4 月 15 日
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 件のコメント
John D'Errico
John D'Errico 2024 年 4 月 15 日
+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.)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by