hello how do I write this function without getting an error saying "variable K has an incorrect value".

1 回表示 (過去 30 日間)
my code is: And so far only the (K) is wrong.
N = 1000;
a= 0;
b= pi;
h = (b-a)/N;
x=a:h:b;
f = x.^2.*sin(x);
F = sum(f*h );
a= 1;
b= 2;
h = (b-a)/N;
x=a:h:b;
g =(x.^3.2 + 2.*x.^2.22 +x + 21) ;
G = sum(g*h) ;
a=-3 ;
b= 3;
h = (b-a)/N;
x=a:h:b;
k =abs(x).*exp(-x).^2 ;
K = sum(k*h);

回答 (2 件)

KSSV
KSSV 2020 年 5 月 27 日
a=-3 ;
b= 3;
h = (b-a)/N;
x=a:h:b;
k =abs(x).*exp(-x.^2) ;
K = sum(k*h);
  10 件のコメント

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


Image Analyst
Image Analyst 2020 年 5 月 27 日
What is "the above technique"?
Try using trapz() instead of sum.
  7 件のコメント
Reza Ghasemi
Reza Ghasemi 2020 年 5 月 28 日
how do i write that? i don't know why KSSV gave me that answer.
Reza Ghasemi
Reza Ghasemi 2020 年 5 月 28 日
uh my bad i gave different question sorry KSSV

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by