MATLAB: Scatter plot for matrix where X is column index

scatter plotmatrix

Hi,
I have a matrix where columns designate an independent sample, and I would like generate scatter plots for this data where X is defined as the sample index. However, I'm having some difficulty figuring out how to make it work.
Marty

Best Answer

colidx = reshape( meshgrid( 1:size(YourMatrix,2), 1:size(YourMatrix,1) ), [], 1);
scatter(colidx, YourMatrix(:))
or
colidx = reshape( repmat(1:size(YourMatrix,2), size(YourMatrix,1)), [], 1);
scatter(colidx, YourMatrix(:))
or if you have a new enough MATLAB,
colidx = repelem(1:size(YourMatrix,2), size(YourMatrix,1) );
scatter(colidx, YourMatrix(:))