# My cos function appears as a straight line instead of as a wave

3 views (last 30 days)
Serena Simpson on 18 Sep 2020
Commented: Serena Simpson on 19 Sep 2020
%Defining given varibles
t = 0 :.1 :3;
f1 = 130;
f2 = 120;
y1 = cosd(2*pi*f1*t);
y2 = cosd(2*pi*f2*t);
%% Section 2: Processing
%equation given
y = 2 .* cos(2.*pi.*(f1+f2./2).*t) .* cos(2.*pi.*(f1-f2./2).*t); %This is my function for the sound waves, however, it appears as a stright line
##### 2 CommentsShowHide 1 older comment
Serena Simpson on 19 Sep 2020
Making the increments smaller worked! Thanks for looking at my code!

David Hill on 19 Sep 2020
f1 = 130;
f2 = 120;
t=0:.001:3;%need smaller incrementing
y = 2*cos(2*pi*(f1+f2/2)*t).*cos(2*pi*(f1-f2/2)*t);
plot(t,y);
##### 2 CommentsShowHide 1 older comment
Serena Simpson on 19 Sep 2020
Thank you so much! It worked. My grade is saved <3

### Community Treasure Hunt

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

Start Hunting!

Translated by