I am trying to run the example discribed in this video: https://www.youtube.com/watch?v=NRKxa8V8RWc
The MATLAB script should be like this:
%% Plot the sum of cosines
t=linspace(0,pi/2,1000);
f1=10;
f2=12;
y1=cos(2*pi*f1*t);
y2=cos(2*pi*f2*t);
y3=y1+y2;
figure;
hold on;
plot(t,y3)
%% Add the envelope to the plot
envelope = [2*cos(pi*(f1.f2)*t); 2*cos(pi*(f1*f2)*t.pi)];
plot(t,envelope)
axis tight
The problem:
At the step "Add the envelope to the plot" there is a . operator at "(f1.f2)" and "t.pi"
According to the video, it should work with the dot, but I am unable to find the proper dot operator, as I tried the dot character and it is not working properly
It is not a .
operator, it is just a minus operator.
change the line:
envelope = [2*cos(pi*(f1-f2)*t); 2*cos(pi*(f1-f2)*t-pi)];
and you should get:
To why it should be a minus, you should check the beat phenomenon