필터 지우기
필터 지우기

Having trouble trying to integrate.

조회 수: 1 (최근 30일)
Caleb Banga
Caleb Banga 2022년 4월 18일
댓글: Torsten 2022년 4월 18일
Below is my code but I have no idea why it will not run.
I just want to integrate the function (x*.515siin(x)) from 0 to 2.794
fx = @(x) x*(103./200)*sin(x));
q= integral(fx,0,2.794)

답변 (1개)

Torsten
Torsten 2022년 4월 18일
fx = @(x) x.*103./200.*sin(x);
q= integral(fx,0,2.794)
  댓글 수: 2
Caleb Banga
Caleb Banga 2022년 4월 18일
%Finding the variance of x
mu= @(x) (x-q)^2*(fx);
M= integral(mu,0,2.794)
%Std of x
x_sq=sqrt(M)
I am having similar issue here too, I do not understand what I am doing wrong.
Torsten
Torsten 2022년 4월 18일
"integral" passes vectors for x to your function, not only scalar values. Therefore, you must use elementwise multiplication and division in your function definition:
fx = @(x) x.*103./200.*sin(x);
q= integral(fx,0,2.794)
mu= @(x) (x-q).^2.*fx(x);
M= integral(mu,0,2.794)
%Std of x
x_sq=sqrt(M)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by