MATLAB: Is there a neat way (functions?) to plot 19 variables against each other

functionsplotsregressionssubplots

Hi,
I am trying to create scatter plots of 19 variables against each other in one figure – so essentially I create a figure with 18×18 subplots. I have managed to do this, but my code calls out every single subplot
i.e. this is my code to creates the first line of the image below. (except without the tick labels)
subplot(18,18,1); plot(phi_peak,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,2); plot(phi_peak_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,3); plot(phi_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,4); plot(phi_c_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,5); plot(phi_r,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,6); plot(phi_r_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,7); plot(W,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,8); plot(Wnat,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,9); plot(Wopt,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,10); plot(Winitial,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,11); plot(LL,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,12); plot(PL,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,13); plot(LI,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,14); plot(PI,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,15); plot(c,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,16); plot(c_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,17); plot(CF,phi,'.'); set(gca,'xtick',[],'ytick',[])
subplot(18,18,18); plot(sigma_n_eff,phi,'.'); set(gca,'xtick',[],'ytick',[])
I was wondering if there were any way to do the same thing, but in functions, so the code is shorter and neater?
Thanks.

Best Answer

Hello Casey, try the 'plotmatrix' command. If you do this as
[S, Ax] = plotmatrix(datamatrix)
then you will have to experiment around, but you can do things like
xlabel(Ax(3,1),'abc')
title(Ax(1,2),'def')