MATLAB: How to create a scatter plot of multiple data with a single call to SCATTER function in MATLAB 7.7 (R2008b)

MATLAB

I have X-data vector and a matrix of Y-data vectors. I am able to plot the X-data vector versus the columns of the Y-data matrix using the PLOT function as shown below:
var = rand(100,5);
var(:,1) = 1:100;
plot(var(:,1),var(:,2:5));
However, when I try the same with the SCATTER function as shown below:
scatter(var(:,1),var(:,2:5));
I receive the following error message:
??? Error using ==> scatter at 54
X and Y must be vectors of the same length.

Best Answer

The ability to create a scatter plot of multiple data with a single call to SCATTER function is not available in MATLAB. The help documentation on the SCATTER function mentions that vectors X and Y must be of the same length.
To work around the limitation, plot individual data using separate calls to SCATTER as shown below:
scatter(var(:,1),var(:,2));
hold on
scatter(var(:,1),var(:,3));
scatter(var(:,1),var(:,4));
scatter(var(:,1),var(:,5));
Related Question