s&smatlab

docx

School

University of Toledo *

*We aren’t endorsed by this school

Course

3200

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

13

Uploaded by DeaconClover13981

Report
COMPUTER EXERCISES 1) a) using unit parabola singularity function. % Define the time range t = -2:0.01:10; % Define the unit step function u = @(t) (t >= 0); % Define the ramp function r = @(t) t .* (t >= 0); % Define the signal signal = 2*u(t) - u(t-2) + u(t-4) - r(t-6) + r(t-8); % Plot the signal plot(t, signal, 'LineWidth', 2); xlabel('t'); ylabel('Signal'); title('Plot of 2u(t) - u(t-2) + u(t-4) - r(t-6) + r(t-8)'); grid on;
b) using unit cubic singularity function. % Define the time range t = -2:0.01:10; % Adjust the time range as needed % Compute the signal y = 2*heaviside(t) - heaviside(t-2) + heaviside(t-4) - (t-6).*heaviside(t-6) + (t-8).*heaviside(t-8); % Plot the signal plot(t, y, 'LineWidth', 2); hold on; % Define the unit cubic singularity function y_cubic = (t(t >= 0)).^3; t_cubic = t(t >= 0); % Plot the unit cubic singularity function plot(t_cubic, y_cubic, 'r--', 'LineWidth', 2); xlabel('t'); ylabel('y(t)'); title('Signal: 2u(t) - u(t-2) + u(t-4) - r(t-6) + r(t-8) with Unit Cubic Singularity'); legend('Original Signal', 'Unit Cubic Singularity'); grid on;
c) using both functions t = linspace(0, 10, 1000); % Time vector plot_signal(t); % Plot the signal x(t) function plot_signal(t) % Define step function u = @(t) (t >= 0); % Define ramp function using cubic singularity r_cubic = @(t) t.^3 .* (t >= 0); % Define ramp function using parabolic singularity r_parabolic = @(t) (t.^2) .* (t >= 0); % Compute the signal x(t) x = 2*u(t) - u(t - 2) + u(t - 4) - r_cubic(t - 6) + r_parabolic(t - 8); % Plot the signal figure; plot(t, x, 'LineWidth', 2); xlabel('Time'); ylabel('x(t)'); title('Plot of x(t)'); grid on; end
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
2) 1a) using unit parabola singularity function. % Step function u = @(t) heaviside(t); % Ramp function r = @(t) t .* u(t); % Unit parabola singularity function unit_parabola = @(t) (abs(t) <= 1) .* (1 - t.^2); % Given signal function xa = @(t, A, T) 2 * A * (u(t) - u(t - T)) + A * (u(t - 2 * T) - u(t - 3 * T)); A = 1; % Amplitude T = 1; % Time period % Time range t = -1:0.01:4; % Compute the signal x_signal = xa(t, A, T); % Plot the signal plot(t, x_signal, 'LineWidth', 2); xlabel('t'); ylabel('xa(t)'); title('Signal xa(t)'); grid on;
2a) using unit parabola singularity function. % Define the time range t = -1:0.01:5; % Define the unit ramp function ramp = @(t) t .* (t >= 0); % Compute the signal Xb(t) Xb = ramp(t) - 2*ramp(t-1) + 2*ramp(t-3) - ramp(t-4); % Plot the signal plot(t, Xb, 'LineWidth', 2); xlabel('t'); ylabel('X_b(t)'); title('Signal: X_b(t) = r(t) - 2r(t-1) + 2r(t-3) - r(t-4)'); grid on;
3a) using unit parabola singularity function. % Define the time range t = 0:0.01:5; % Define the ramp function ramp = @(t) max(0, t); % Define the unit step function unit_step = @(t) t >= 0; % Compute the signal xc(t) xc = ramp(t - 1) + 0.5 * unit_step(t - 1.5) - 2 * ramp(t - 2) - 0.5 * unit_step(t - 2.5) + ramp(t - 3); % Plot the signal plot(t, xc, 'LineWidth', 2); xlabel('t'); ylabel('x_c(t)'); title('Signal: x_c(t) = r(t-1) + 0.5u(t-1.5) - 2r(t-2) - 0.5u(t-2.5) + r(t-3)'); grid on;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
1b) using unit cubic singularity function. % Define the time range t = 0:0.01:6; % Define parameters A = 1; % Amplitude T = 1; % Period % Define the unit cubic singularity function unit_cubic_singularity = @(t) (t >= 0) .* t.^3; % Compute the signal xa = 2*A*(heaviside(t) - heaviside(t - T)) + A*(heaviside(t - 2*T) - heaviside(t - 3*T)) + unit_cubic_singularity(t); % Plot the signal plot(t, xa, 'LineWidth', 2); xlabel('t'); ylabel('x_a(t)'); title('Signal: x_a(t) = 2A[u(t)-u(t-T)] + A[u(t-2T)-u(t-3T)] + Unit Cubic Singularity'); grid on;
2b) using cubic singularity function % Define the time range t = 0:0.01:5; % Define the ramp function ramp = @(t) max(0, t); % Define the unit cubic singularity function unit_cubic_singularity = @(t) (t >= 0) .* t.^3; % Compute the signal Xb = ramp(t) - 2*ramp(t - 1) + 2*ramp(t - 3) - ramp(t - 4) + unit_cubic_singularity(t); % Plot the signal plot(t, Xb, 'LineWidth', 2); xlabel('t'); ylabel('Xb(t)'); title('Signal: Xb(t) = r(t) - 2r(t-1) + 2r(t-3) - r(t-4) + Unit Cubic Singularity'); grid on;
3b) using cubic singularity function function plot_cubic_signal() % Define the time vector t = linspace(0, 5, 1000); % Adjust the time range and resolution as needed % Define the ramp function using cubic singularity r_cubic = @(t) t.^3 .* (t >= 0); % Define the step function u = @(t) (t >= 0); % Compute each component of xc(t) using the cubic singularity function xc_r1 = r_cubic(t - 1); % r(t-1) xc_r2 = -2 * r_cubic(t - 2); % -2r(t-2) xc_r3 = r_cubic(t - 3); % r(t-3) xc_u1_5 = 0.5 * u(t - 1.5); % 0.5u(t-1.5) xc_u2_5 = -0.5 * u(t - 2.5); % -0.5u(t-2.5) % Compute the signal xc(t) xc = xc_r1 + xc_u1_5 + xc_r2 + xc_u2_5 + xc_r3; % Plot the signal xc(t) figure; plot(t, xc, 'LineWidth', 2); xlabel('Time'); ylabel('xc(t)'); title('Plot of xc(t) using Cubic Singularity'); grid on;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
1c) using both functions A = 1; % Amplitude T = 1; % Period t = linspace(-1, 5, 1000); % Time vector plot_signal(A, T, t); function plot_signal(A, T, t) % Define step function u = @(t) (t >= 0); % Step function % Define parabolic singularity function parabola_singularity = @(t) (t.^2) .* ((0 <= t) & (t < 1)) + (2 - t).^2 .* ((1 <= t) & (t < 2)); % Define cubic singularity function cubic_singularity = @(t) (t.^3) .* ((0 <= t) & (t < 1)) + (2 - t).^3 .* ((1 <= t) & (t < 2)); % Compute the signal xa(t) xa = 2*A*(u(t) - u(t-T)) + A*(parabola_singularity(t-2*T) - cubic_singularity(t-3*T)); % Plot the signal figure; plot(t, xa, 'LineWidth', 2); xlabel('Time'); ylabel('x_a(t)'); title('Plot of x_a(t)'); grid on; end
2c) using both functions t = linspace(0, 5, 1000); % Time vector Xb = 1; % Amplitude (optional) plot_signal(Xb, t); function plot_signal(Xb, t)% Define ramp function using cubic singularity ramp_cubic = @(t) t.^3 .* (t >= 0);% Define ramp function using parabolic singularity ramp_parabolic = @(t) (t.^2) .* (t >= 0); % Compute the signal Xb(t) Xb_signal = ramp_parabolic(t) - 2 * ramp_parabolic(t - 1) + 2 * ramp_parabolic(t - 3) - ramp_parabolic(t - 4); % Plot the signal figure; plot(t, Xb_signal, 'LineWidth', 2); xlabel('Time'); ylabel('Xb(t)'); title('Plot of Xb(t)'); grid on; end
3c) using both functions t = linspace(0, 5, 1000); % Define the time vector plot_signal(t); % Plot the signal xc(t) function plot_signal(t) % Define the ramp function using cubic singularity r_cubic = @(t) t.^3 .* (t >= 0); % Define the parabola function using parabola singularity parabola = @(t) t.^2 .* (t >= 0); % Compute the signal xc(t) xc = r_cubic(t - 1) + 0.5 * parabola(t - 1.5) - 2 * r_cubic(t - 2) - 0.5 * parabola(t - 2.5) + r_cubic(t - 3); % Plot the signal figure; plot(t, xc, 'LineWidth', 2); xlabel('Time'); ylabel('xc(t)'); title('Plot of xc(t)'); grid on; end
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help