how to create this plot

1 view (last 30 days)
iman
iman on 24 Dec 2013
Answered: Image Analyst on 24 Dec 2013
plot for this sequence cos(pi/3n)+0.75cos(2pi/3n) in discrete time tnx

Accepted Answer

Image Analyst
Image Analyst on 24 Dec 2013
I already did it in your duplicate question. Here it is again:
% Create data.
x = -3:11;
y1 = cos(x .* pi/3)+0.75*cos(2*x*pi/3);
y2 = [0,0,0,1,1,1,1,1,1,1,1,0,0,0,0]
y3 = y1 .* y2;
% Plot top graph.
subplot(3,1,1);
stem(x,y1, 'Color', 'k', 'MarkerFaceColor', 'k', 'LineWidth', 3);
xlim([-3,11]);
ylim([-2,2]);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Plot top graph.
subplot(3,1,2);
stem(x,y2, 'Color', 'k', 'MarkerFaceColor', 'k', 'LineWidth', 3);
xlim([-3,11]);
ylim([0, 1.2]);
grid on;
% Plot top graph.
subplot(3,1,3);
stem(x,y3, 'Color', 'k', 'MarkerFaceColor', 'k', 'LineWidth', 3);
xlim([-3,11]);
ylim([-2, 2]);
grid on;

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 24 Dec 2013
n=0:10
y=cos(pi./(3*n))+0.75*cos(2pi./(3*n)
stem(n,y)

Categories

Find more on 2-D and 3-D Plots 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!