Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Mark Wilson 214136683
- % Artem Rozenfeld 214152847
- %% Question 1a
- clear;
- t = 0:0.01:10;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 2*pi/6);
- plot(t,y)
- xlabel('time');
- ylabel('function output')
- grid;
- legend('x(t)')
- title('Question 1a')
- %% Question 1b
- clear;
- t = 0:0.01:10;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 0);
- plot(t,y)
- hold on;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi/4);
- plot(t,y)
- hold on;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi/2);
- plot(t,y)
- hold on;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + 3*pi/4);
- plot(t,y)
- hold on;
- y = 0.1*sind(t)+ 0.2*cos(4*pi*t + pi);
- plot(t,y)
- hold off;
- xlabel('time');
- ylabel('function output')
- grid;
- legend('ø = 0','ø = 45','ø = 90','ø = 135','ø = 180')
- title('Question 1b')
- %% Question 1c
- % Yes, X(t) is a periodic signal.
- % It is periodic because the signal repeats
- % in a set period with a repeating frequency of 2Hz.
- % It might look like the function is rising within the
- % given time, because the period is larger than the set t.
- %% Question 2a
- clear;
- t = 0:0.01:10;
- y = exp(-0.1*pi*t);
- plot(t,y)
- hold on;
- y = exp(-0.1*pi*t).*cos(2*pi*t);
- plot(t,y,':r')
- hold off;
- ylabel('function output');
- xlabel('time');
- grid;
- legend('e(t)','x2(t)');
- title('Question 2a')
- %% Question 2b
- clear;
- t = 0:0.01:10;
- y = heaviside((exp(-0.1*pi*(t-2)).*cos(2*pi*(t-2))));
- plot(t,y)
- ylabel('function output');
- xlabel('time');
- grid;
- legend('x2b(t)');
- title('Question 2b')
- %% Question 3a
- clear;
- Z = 1 + -3i + (7i*10/(7i+10));
- display(Z)
- %% Question 3b
- clear;
- Z = 1 + -3i + (7i*10/(7i+10));
- t = 0:0.01:2;
- V = 50*sin(10*pi*t);
- plot(t,V)
- hold on;
- I = (50*sin(10*pi*t - atan(imag(Z)/real(Z)))/abs(Z));
- plot(t,I)
- hold off
- ylabel('function output');
- xlabel('time');
- grid;
- legend('V(t)','I(t)');
- title('Question 3b')
- %% Question 4
- clear;
- output=squarewave(10,2,300);
- hold on;
- output=squarewave(10,2,1);
- hold on;
- output=maxpower(10,2,1);
- hold off;
- legend('square wave','fundamental square wave','maxpower')
- title('Question 4')
- %% squarewave
- function output = squarewave(v,f,length);
- t = 0:0.001:1;
- y = 0;
- for n=1:2:length
- output = ((4*v)/pi)*((1/n)*sin(n*2*pi*f*t));
- y = output + y;
- end
- plot(t,y)
- ylabel('function output');
- xlabel('time');
- grid;
- legend('show');
- end
- %% maxpower
- function output = maxpower(v,f,length);
- t = 0:0.001:1;
- y = 0;
- for n=1:2:length
- output = ((4*v)/pi)*((1/n)*sin(n*2*pi*f*t));
- y = output + y;
- end
- y = y.^2;
- plot(t,y)
- ylabel('function output');
- xlabel('time');
- grid;
- legend('show');
- end
- %% Question 5a
- clear;
- t=-5:.001:5;
- y=-3.*sign(t).*exp(2i*pi*t+0.25*t);
- subplot(2,1,1);
- plot(t,real(y));
- title('CT signal real');
- xlabel('time');
- ylabel('function output');
- subplot(2,1,2);
- plot(t,imag(y));
- title('CT signal imaginary ');
- xlabel('time');
- ylabel('function output');
- %% Question 5b
- clear;
- t=-5:.001:5;
- y=-3.*sign(t).*exp(2i*pi*t+0.25*t);
- z=y.*rectangularPulse(t/4);
- subplot(2,1,1);
- plot(t,real(z));
- title('Rectangular Pulse Signal real ');
- xlabel('time');
- ylabel('function output');
- subplot(2,1,2);
- plot(t,imag(z));
- title('Rectangular Pulse Signal imaginary ');
- xlabel('time');
- ylabel('function output');
- %% Question 6
- clear;
- t = -2:0.01:2;
- if (-2<=t<0)
- y = 0.25*t;
- plot(t,y)
- hold on
- end
- if (0<=t<0.5)
- y = 1.5;
- plot(t,y)
- hold on
- end
- if (0.5<=t<=2)
- y = -t +2;
- plot(t,y)
- hold off
- end
- ylabel('function output');
- xlabel('time');
- grid;
- legend('0.25t','1.5','-t+2')
- title('Question 6')
- axis([-2,2,-0.5,2]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement