hello how do I write this function without getting an error saying "variable K has an incorrect value".
Mostrar comentarios más antiguos
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);
Respuestas (2)
KSSV
el 27 de Mayo de 2020
a=-3 ;
b= 3;
h = (b-a)/N;
x=a:h:b;
k =abs(x).*exp(-x.^2) ;
K = sum(k*h);
10 comentarios
Reza Ghasemi
el 27 de Mayo de 2020
Reza Ghasemi
el 27 de Mayo de 2020
KSSV
el 27 de Mayo de 2020
Change the line:
k =abs(x).*exp(-x).^2 ;
to
k =abs(x).*exp(-x.^2) ;
I got K value as 0.99987.
Reza Ghasemi
el 27 de Mayo de 2020
Reza Ghasemi
el 27 de Mayo de 2020
KSSV
el 27 de Mayo de 2020
What do you mean by ran without output?
Reza Ghasemi
el 27 de Mayo de 2020
Reza Ghasemi
el 27 de Mayo de 2020
Reza Ghasemi
el 27 de Mayo de 2020
Reza Ghasemi
el 27 de Mayo de 2020
Image Analyst
el 27 de Mayo de 2020
0 votos
What is "the above technique"?
Try using trapz() instead of sum.
7 comentarios
Reza Ghasemi
el 28 de Mayo de 2020
Reza Ghasemi
el 28 de Mayo de 2020
Walter Roberson
el 28 de Mayo de 2020
trapz is not going to agree with the required summation; the endpoints are handled differently.
trapz is effectively 
Reza Ghasemi
el 28 de Mayo de 2020
Walter Roberson
el 28 de Mayo de 2020
No, K =
which is not the same as 
which is not the same as
Reza Ghasemi
el 28 de Mayo de 2020
Reza Ghasemi
el 28 de Mayo de 2020
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


