Feeds:
Posts
Comments

Archive for November 3rd, 2009

Matlab Magic

Images are sometimes too easy to make.

Images are sometimes too easy to make.

I occasionally stumble across some interested images in Matlab while testing things out. Particular when trying to run random data through my programs to see if the results are from the data instead of the program itself. In this case I cross-correlation a normalized magic square to get the above surface plot. It looked neat so I kept the code:

mg=magic(40);

 

points=size(mg,1);

mg_norm=zeros(size(mg));

 

for i=1:points

norm=mg(i,:)./max(mg(i,:));

norm=norm-mean(norm);

mg_norm(i,:)=norm;

end

 

a=xcorr2(mg_norm);

a=a.*(1/max(max(a)));

 

figure;

surf(a);

clear a i mg mg_norm norm points

Advertisements

Read Full Post »