MATLAB: Need help in coding

fft() and fftshift()

A PM signal x(t) = 3 cos(10πt + 0.4cos2πt) is generated using the carrier signal c(t) = 3 cos(10πt). Plot the PM signal x(t) and the carrier signal c(t) together in one plot, for t = 0 to 2 sec, in steps of 5 msec. Use different colours for x(t) versus c(t) in your plot.
How do i plot in MATLAB?

Best Answer

Use plot(), etc. Here's a start:
t = 0 : 0.05 : 2;
ct = 3 * cos(10 * pi * t);
xt = 3 * cos(10 * pi * t + 0.4 * cos(2 * pi * t));
plot(t, ct, 'r-', 'LineWidth', 2);
hold on;
plot(t, xt, 'b-', 'LineWidth', 2);
xlabel('t', 'FontSize', 20);
ylabel('x(t)', 'FontSize', 20);
legend('c(t)', 'x(t)');