This code provides 8 plots, It needs to be sub plotted into 4 plots per plot (2
ID: 3628459 • Letter: T
Question
This code provides 8 plots, It needs to be sub plotted into 4 plots per plot (2 plots with 4 graphs each). I have tried many set-ups and can not the results I want so please explain.% helpdesk
% help
% help general
% help plot
% help stem
% lookfor cos
close all; clear all;
x = [1 3 4 6 9];
y = x + 3
stem(x); xlabel('My x axis'); ylabel('My y axis'); title('No title --:)');
grid on;
hold on;
stem(y);
n = 0:1:59; % generate a vector, it is the same as n = 0:19
figure;
stem(n); % plot n
y = cos(2*pi*n/7);
z = y.*sin(2*pi*n/7); %dot means times sample by sample
figure;
stem(y);
figure;
stem(n,y); %plot n versus y
xlabel('n'); %plot x label
ylabel('y[n]'); %plot y label
title('A sample sequence y[n] = cos(2pi n/7)'); % title of this figure
figure; %generate another figure instance
plot(n,y,'r-d'); %another plot function
hold on;
plot(n,z,'g-o');
clear all;
%here we use for loop to generate signal
disp(i); disp(j);
aLenthX = 30;
for i = 1:aLenthX % pay attention that index in Matlab starts from 1
y(i) = i*2 - 10;
end
n = 0:aLenthX-1;
figure; hold on;
stem(n,y,'r');
disp(i);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% how to define a function %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x = rand(10,10);
figure; surf(x);
addpath('C:workCourse0DSPIunctions');
[mean, std] = stat(x);
clear x;
x = slope(100);
figure; stem(x);
Explanation / Answer
x=0:0.01:2*pi; y1=x; y2=sin(x); y3=cos(x); y4=y2+y3; y5=-x; y6=-sin(x); y7=-cos(x); y8=y6+y7; subplot(4,2,1),plot(x,y1); grid on; title('plot 1'); subplot(4,2,3),plot(x,y2); grid on; title('plot 2'); subplot(4,2,5),plot(x,y3); grid on; title('plot 3'); subplot(4,2,7),plot(x,y4); grid on; title('plot 4'); subplot(4,2,2),plot(x,y5); grid on; title('plot 5'); subplot(4,2,4),plot(x,y6); grid on; title('plot 6'); subplot(4,2,6),plot(x,y7); grid on; title('plot 7'); subplot(4,2,8),plot(x,y8); grid on; title('plot 8');