Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %---------------------------------------
- % Fill in your group number.
- GroupNumber = 3;
- % Fill in your student Name and ID.
- Students(1).Name = 'Tyler Young';
- Students(1).ID = '260730324';
- Students(2).Name = 'Jamie McLeish';
- Students(2).ID = '260708573';
- %---------------------------------------
- %-Documentation-
- help dirac
- doc abs
- %-Arrays-
- dt = 0.01; % timestep of discrete signal in seconds
- T = 10; % Final value of the time signal in seconds
- % This creates an array |t = [0, 0.01, 0.02, 0.03, ..., 9.98, 9.99, 10.0]|.
- t = 0:dt:T; % time signal
- x1 = sin(2*pi*t);
- x2 = zeros(size(t)); % create a zero signal with the same size as time
- x2(t < 5) = t(t < 5); % value is equale to time, but only when time < 5
- x2(t >= 5) = -t(t >= 5) + 10; % value is equale to -time+10, but only when time >= 5
- %-Plotting Signals-
- figure;
- hold on;
- grid on;
- plot(t, x1);
- plot(t, x2);
- title(sprintf('Group %d - Example plot', GroupNumber));
- xlabel('Time (seconds)')
- ylabel('Signal')
- legend('x_1(t)', 'x_2(t)')
- hold off;
- %-Matrices-
- A = [8, 1, 6; 3, 5, 7; 4, 9, 2]
- det(A)
- eig(A)
- inv(A)
- %-Saving/Loading Data-
- example = sprintf('A variable generated by groupe <%d>', GroupNumber);
- save('Lab01.mat', 'example')
- clear example
- load('Lab01.mat', 'example')
- disp(example)
- %---Question 1---
- t = 0:dt:T; % time signal
- y1(t >= 0) = 1;
- y2(t < 5) = 0;
- y2(t >= 5) = -1;
- y3 = zeros(size(t));
- y3(t >=0) = 0.1*t(t >= 0);
- y4 = exp(-t/10);
- figure;
- hold on;
- % Fill in your plots command
- plot(t, y1);
- plot(t, y2);
- plot(t, y3);
- plot(t, y4);
- title(sprintf('Group %d - Question 1 - Signals', GroupNumber));
- xlabel('Time (seconds)')
- ylabel('Signals')
- grid on;
- legend('y_1(t)', 'y_2(t)', 'y_3(t)', 'y_4(t)', 'location', 'best')
- %-Computing Laplace Transforms-
- syms t s
- f = exp(-t);
- F = laplace(f, t, s);
- help laplace
- simplify(2/(s + 1)-s/(s + 1)^2)
- help sym/simplify
- %---Question 2---
- syms t s
- f1 = dirac(t)
- f2 = t^2 + 4*t + 1
- f3 = t*exp(-t) + 0.5*exp(-t) + exp(-3*t)
- f4 = sin(2*t) + cos(t).^2
- f5 = exp(-t)*sin(5*t + pi/3) + (t.^2)*exp(-2*t)
- %---Question 3---
- F1 = simplify(laplace(f1, t, s))
- F2 = simplify(laplace(f2, t, s))
- F3 = simplify(laplace(f3, t, s))
- F4 = simplify(laplace(f4, t, s))
- F5 = simplify(laplace(f5, t, s))
- %-Computing Inverse Laplace Transforms-
- ilaplace(F, s, t);
- %---Question 4---
- syms s t
- G1 = 1/s
- G2 = 1/(s*(s+1))
- G3 = 5/(s^2 +25)
- G4 = (10*s + 1)/(s^2 +2*s +10)
- G5 = (2*(s+1)*(s.^2+4))/((s.^2+4*s+1)*(s.^2+9))
- g1 = simplify(ilaplace(G1, s, t))
- g2 = simplify(ilaplace(G2, s, t))
- g3 = simplify(ilaplace(G3, s, t))
- g4 = simplify(ilaplace(G4, s, t))
- g5 = simplify(ilaplace(G5, s, t))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement