draw mr frundles in matlab in matlab

To draw Mr. Frundles in Matlab, we can use the built-in rectangle() function to draw different rectangles with different colors at appropriate positions. Here's an example code:

main.m
% Define colors
yellow = [1 0.8 0];
blue = [0 0.4 1];
white = [1 1 1];

% Draw Mr. Frundles
figure;
hold on;

% head
rectangle('Position', [1, 6, 4, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');
% eyes
rectangle('Position', [2, 7, 1, 1], ...
          'FaceColor', white, 'EdgeColor', 'none');
rectangle('Position', [4, 7, 1, 1], ...
          'FaceColor', white, 'EdgeColor', 'none');
% pupils
rectangle('Position', [2.5, 7.5, 0.5, 0.5], ...
          'FaceColor', blue, 'EdgeColor', 'none');
rectangle('Position', [4.5, 7.5, 0.5, 0.5], ...
          'FaceColor', blue, 'EdgeColor', 'none');
% mouth
rectangle('Position', [2.5, 5, 2, 1], ...
          'Curvature', [1 1], 'FaceColor', 'none', ...
          'EdgeColor', blue, 'LineWidth', 2);

% arms
rectangle('Position', [0.5, 6, 1, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');
rectangle('Position', [6.5, 6, 1, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');

% legs
rectangle('Position', [1.5, 2, 1, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');
rectangle('Position', [4.5, 2, 1, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');

% body
rectangle('Position', [2, 2, 3, 4], ...
          'FaceColor', yellow, 'EdgeColor', 'none');

hold off;
axis equal;
axis off;
1289 chars
47 lines

This will produce the following plot:

Mr. Frundles plot

Feel free to adjust the positions, colors, and sizes of the rectangles to make it look more like Mr. Frundles (or any other character you want to draw).

gistlibby LogSnag