how to integral f(x).*g(x)

1 view (last 30 days)
Dion Akmal
Dion Akmal on 24 Mar 2021
Edited: Dion Akmal on 24 Mar 2021
can somebody help me with my problem. here is my code and it cant be run
f = 0.05:0.05:0.4
t=0:.01:20
X=cos(2*pi*f*t)
Y=cos(2*pi*f*t)
g = @(t) X.*Y;
I = integral(g,0,20,'ArrayValued',true);

Accepted Answer

Matt J
Matt J on 24 Mar 2021
f = 0.05:0.05:0.4;
% t=0:.01:20;
X=@(t) cos(2*pi*f*t);
Y=@(t) cos(2*pi*f*t);
g=@(t) X(t).*Y(t);
I = integral(g,0,20,'ArrayValued',true)
I = 1×8
10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000
  3 Comments
Matt J
Matt J on 24 Mar 2021
You're welcome, but please Accept-click the answer to indicate that it helped.
Dion Akmal
Dion Akmal on 24 Mar 2021
Edited: Dion Akmal on 24 Mar 2021
can you help me again sir ?, why my code below is error, f in my code is scalar that is 0.05, 0,1 , 0.15, 0.2, ...,0.4
f= 0.05 : 0.05 : 0.4
t = 0 : 0.001 : 20
Y = cos(2*pi*0.1*t)

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!