linexy in matlab

To plot XY data in MATLAB, you can use the plot function. First, define the X and Y data points as two separate vectors, then call the plot function with those vectors as inputs:

main.m
x = [1 2 3 4 5];
y = [2 4 6 8 10];

plot(x,y);
47 chars
5 lines

This will create a simple XY line plot with X values on the horizontal axis and Y values on the vertical axis. You can customize the plot by adding options to the plot function, such as changing the line color or style:

main.m
x = [1 2 3 4 5];
y = [2 4 6 8 10];

plot(x,y,'r--'); % red dashed line
71 chars
5 lines

This will create the same plot as above, but with a red dashed line instead of a solid blue line. You can also add axis labels and a title to the plot using the xlabel, ylabel, and title functions:

main.m
x = [1 2 3 4 5];
y = [2 4 6 8 10];

plot(x,y,'r--');
xlabel('X');
ylabel('Y');
title('XY Plot');
97 chars
8 lines

This will create a labeled plot with "X" on the horizontal axis, "Y" on the vertical axis, and a title of "XY Plot".

gistlibby LogSnag