フィルターのクリア

Error integrating the sine function

3 ビュー (過去 30 日間)
Lewis HC
Lewis HC 2020 年 7 月 8 日
コメント済み: Lewis HC 2020 年 7 月 10 日
Hi friends, could you help me with this qeustion:
Write a code that numerically integrates the function y = sin (x) in the interval of x of [0 2pi] and calculates the error with respect to the exact integral for each delta x of integration [pi / 4 pi / 20 pi / 100].
I tried to began thus:
x=0:0.1:2*pi;
y1=sin(x);
dx = x(2)-x(1);
y2 = cumsum(x1.*dx);
y2 = y2-1-y2(1);
But I don't know how to do the error
Thanks for your help!

採用された回答

madhan ravi
madhan ravi 2020 年 7 月 8 日
ERROR = abs(y2(:) - [pi / 4 pi / 20 pi / 100])
  1 件のコメント
Lewis HC
Lewis HC 2020 年 7 月 10 日
Thank you dear friend!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by