Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Easter eggs as Matlab code

Asked by Jan Simon on 18 Mar 2013

Dear Matlab community,

Unfortunately I ran out of eggs. I've looked in the FileExchange and found christmas trees, valentine hearts, fireworks and a surprisingly large number of arrows and progressbars. But unfortunately no eggs, most of all no beautiful easter eggs.

I'd be very glad if you could provide some colored eggs as Matlab code.

Please vote all nice solutions.

THANKS!

3 Comments

Jan Simon on 18 Mar 2013

Kind regards to Matt Fig - I miss your humpday puzzlers.

Leah on 18 Mar 2013

2D or 3D?

Jan Simon on 18 Mar 2013

@Leah: Text and sound is welcome also, when an ovate shape can be recognized. The more beautiful, the better.

Of course I will show, what I have done so far also.

Jan Simon

Products

No products are associated with this question.

4 Answers

Answer by Leah on 18 Mar 2013

Okay here is my egg so far. I would like to have a fancy color map, but I thought others might like to make one. I used Dan's post (link below), his are very fancy

http://danielwalsh.tumblr.com/post/2742366331/mathematically-defined-easter-eggs

c=.2;
b=1.7;
theta=linspace(0,2*pi,40);
phi=linspace(0,pi,40);
[theta,phi]=meshgrid(theta,phi);
x=(1+c*phi).*sin(phi).*cos(theta);
y=(1+c*phi).*sin(phi).*sin(theta);
z=b*cos(phi);
M=mesh(x,y,z,'facecolor','interp','facelighting','phong');
cmap=colormap(jet);
linspace(0,2*pi,32)
axis equal
axis off

0 Comments

Leah
Answer by Daniel on 18 Mar 2013

As inspiration you might want to check out how to make eggs in LaTeX. I used that as my starting point. I was thinking about an answer where I just hack tex.m to include the code, but I think TikZ requires PDF output and not DVI and I am not sure tex.m can handle pdf output.

The LaTeX answers provide a link to the shape of an egg. That is enough to get started

t = -pi:0.01:pi;
H = 1;
x = H*0.78.*cos(t./4).*sin(t);
y = -H*cos(t);
fill(x, y, [1, 0.87, 0.68])
axis square
axis([-1, 1, -1, 1]);
axis off

The next step would be to make it 3D, and then play with color, lighting/shading and texture. It is a start ...

0 Comments

Daniel
Answer by Sean de Wolski on 18 Mar 2013

Thanks for the Monday challenger.

[x,y,z] = sphere(100);
x = 1.7./(1-0.4*x);
figure(10);
h = surf(x,y,z);
cdata = imresize(imread('onion.png'),size(x));
set(h,'CDataMapping','Direct','FaceColor','texturemap','CData',cdata);

0 Comments

Sean de Wolski
Answer by Image Analyst on 18 Mar 2013

At first I thought you meant that they took the Easter eggs (like spy, why, penny, etc.) out of the new version of MATLAB. But then I figured out you actually want code to draw pictures of fancy design Easter eggs. I don't have any code for that. I wish they'd refresh their Easter eggs - they're getting kind of stale.

I do have some nice puzzler codes though. One to solve a maze, and another that does a Monte Carlo simulation on the Monty Hall problem, which I haven't posted anywhere, but I could if anyone is interested.

Here's one I ran across that was kind of fun because it's counter-intuitive (though it's really easy to solve): "You have 100 pounds of Martian potatoes, which are 99 percent water by weight. You let them dehydrate until they’re 98 percent water. How much do they weigh now?"

1 Comment

Jan Simon on 18 Mar 2013

Let me reformat your text a little bit:

                      "You
                   have   100
                pounds of Martian
               potatoes, which are
              99 percent  water  by
              weight.  You let them 
               dehydrate until they
                are 98 percent water.
                 How  much do they
                    they  weigh 
                       now?"
Image Analyst

Contact us