create a graph of an input signal of 2 volts peak-to-peak at 1 kilohertz in matlab

main.m
% Define the signal parameters
amplitude = 2; % 2 volts peak-to-peak
frequency = 1000; % 1 kHz
sampling_frequency = 10 * frequency; % Ensure sampling frequency is at least 10 times higher than the signal frequency

% Generate the time vector
t = 0 : 1/sampling_frequency : 1/frequency;

% Generate the input signal
signal = amplitude/2 * sin(2*pi*frequency*t);

% Plot the graph
plot(t, signal);
xlabel('Time (s)');
ylabel('Voltage (V)');
title('Input Signal of 2V Peak-to-Peak at 1kHz');
489 chars
17 lines

This code will create a graph of an input signal with an amplitude of 2 volts peak-to-peak at 1 kilohertz in MATLAB.

related categories

gistlibby LogSnag