MATLAB BATMAN Equation Plot

The BATMAN plot has been in news since google has plotted it on its website.

Google BATMAN Plot
Google BATMAN Plot

The plot, itself when taken as a whole, is not a function, as its clear from the above google plot, that it has 2 values of Y-Axis for a single value of X-Axis, & vice versa. Also its clear from the above plot that its a piecewise function, we have plotter the BATMAN head, wings (Upper & Lower part), lover body, etc separately. Thus mathematically it is feasible only when it has to be plotted piece wise.

So, if someone want to plot it, in MATLAB. He has to do like the same thing as done above. And how the MATLAB Batman equations Plot looks like, is given below:
hold on

% Outer wings
f1 = '(x/7)^2 * sqrt(abs(abs(x)-3)/(abs(x)-3)) + (y/3)^2 * sqrt(abs(y + 3/7*sqrt(33))/(y + 3/7*sqrt(33))) - 1';
ezplot(f1,[-8 8 -3*sqrt(33)/7 6-4*sqrt(33)/7]);


% Bottom
f2 = 'abs(x/2)-(3*sqrt(33)-7) * x^2/112 - 3 + sqrt(1-(abs(abs(x)-2)-1)^2) - y';
ezplot(f2,[-4 4]);


% Outer ears
f3 = '9 * sqrt(abs((1-abs(x))*(abs(x)-0.75)) / ((1-abs(x))*(abs(x)-0.75))) - 8*abs(x) - y';
ezplot(f3,[-1    -0.75 -5 5]);
ezplot(f3,[ 0.75  1    -5 5]);


% Inner ears
f4 = '3*abs(x) + 0.75*sqrt(abs((0.75-abs(x))*(abs(x)-.5)) / ((.75-abs(x))*(abs(x)-.5))) - y';
ezplot(f4,[-0.75 0.75 2.25 5]);


% Connect inner ears (flat line)
f5 = '2.25*sqrt(abs(((0.5-x)*(0.5+x))/((0.5-x)*(0.5+x)))) - y';
ezplot(f5,[-0.5 0.5 -5 5]);


% Inner wings
f6 = '6*sqrt(10)/7 + (1.5-0.5*abs(x)) * sqrt(abs(abs(x)-1) / (abs(x)-1)) - 6*sqrt(10)/14 * sqrt(4-(abs(x)-1)^2) - y';
ezplot(f6,[-3 -1 -5 5]);
ezplot(f6,[ 1  3 -5 5]);


% Change line color and width
set(get(gca,'children'),'Color','b','Linew',2)

% Title
title('Batman'); 

 So here is the curious result that you will get after running the above code:
 
MATLAB BATMAN Equation Plot
MATLAB BATMAN Equation Plot
So just have a try with the code, & if you get something interesting out of it. Just comment back with the code or mail me, I will love to add that also as an extension of this article.

 

0 comments: