create a graph of an input signal of 2 volts peak-to-peak at 1 kilohertz in red color and an output signal of 2 volts peak-to-peak at 1 kilohertz with a phase angle of 180 degrees in blue color in matlab

main.m
% Generate time vector
fs = 10000; % Sampling frequency in Hz
t = 0:1/fs:1-1/fs; % Time vector from 0 to 1 second

% Input signal
f_input = 1000; % 1 kHz frequency
input_signal = 1 * sin(2*pi*f_input*t); % Amplitude of 1 and no phase shift

% Output signal
f_output = f_input; % Same frequency as input
output_signal = 1 * sin(2*pi*f_output*t + pi); % Amplitude of 1 and 180 degrees phase shift

% Plot signals
figure;
plot(t, input_signal, 'r', t, output_signal, 'b');
xlabel('Time (s)');
ylabel('Amplitude');
title('Input and Output Signals');
legend('Input Signal (1 kHz)', 'Output Signal (1 kHz with 180 degree phase shift)', 'Location', 'northwest');
656 chars
20 lines

related categories

gistlibby LogSnag