plot 2 vectors in matlab

To plot two vectors in Matlab, you can use the plot function. Here is an example code:

main.m
% Define two vectors
x = [1, 2, 3, 4, 5];
y = [2, 4, 6, 8, 10];

% Plot the vectors
plot(x, y);

% Set axis labels and title
xlabel('x');
ylabel('y');
title('Plot of Two Vectors');
181 chars
12 lines

This code will create a plot with the x and y values from the vectors x and y. The plot function will connect the points with lines. The xlabel, ylabel, and title functions are used to set the axis labels and title of the plot.

You can run this code in the Matlab command window or in a Matlab script file.

related categories

gistlibby LogSnag