MatLab (presented data) [closed]

You can pass a vector as the first input to plot and a matrix (with a dimension which matches the size of the first vector) as the second input and it will create a plot for each pairing of the first vector and each row/column of the second input.

plot(X, Y, 'o')

enter image description here

This will automatically color each row of Y differently. If you’d like the entire plot to be the same color, you can specify the color when creating the plot

plot(X, Y, 'o', 'Color', 'black')

enter image description here

If, however, you want to use scatter, you’ll need to make sure that the two inputs have the same size. You can do this by applying repmat to X to make it the same size as Y

xx = repmat(X, size(Y, 1), 1);
scatter(xx(:), Y(:)) 

enter image description here

Browse More Popular Posts

Leave a Comment