plot discrete signal in matlab

To plot a discrete signal in MATLAB, you can use the stem function which displays data points as markers on the stem of a graph. Here is an example:

main.m
% generate a discrete signal
x = [1, 2, 1, -1, 0, 1, 2];

% plot the signal using stem function
stem(x);

% add x and y label to the plot
xlabel('Sample Index');
ylabel('Amplitude');
title('Discrete Signal');
209 chars
11 lines

This will display a plot of the discrete signal with the sample index on the x-axis and the signal amplitude on the y-axis. You can customize the plot by changing the x and y label or the title.

related categories

gistlibby LogSnag