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

4 次查看(过去 30 天)
Dion Akmal
Dion Akmal 2021-3-24
编辑: Dion Akmal 2021-3-24
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);

采纳的回答

Matt J
Matt J 2021-3-24
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 个评论
Matt J
Matt J 2021-3-24
You're welcome, but please Accept-click the answer to indicate that it helped.
Dion Akmal
Dion Akmal 2021-3-24
编辑:Dion Akmal 2021-3-24
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)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by