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!

*No products are associated with this question.*

Answer by Daniel Shub
on 18 Mar 2013

Accepted answer

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 ...

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

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);

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?"

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?"

Related Content

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 3 Comments

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/67654#comment_137317

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

## Leah (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/67654#comment_137331

2D or 3D?

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/67654#comment_137350

@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.