draw a pumpkin in matlab

To draw a pumpkin in MATLAB, we can use the patch function to draw a filled polygon with rounded edges. Here is an example code:

main.m
% Define coordinates of the pumpkin shape
x = [-1 -1 1 1.5 1 0.5 0 0 -0.5 -1];
y = [1 -1 -1 -0.5 0.5 1.5 2 2 1.5 1];

% Create a figure and draw the pumpkin shape
figure;
patch(x, y, 'orange', 'LineWidth', 2);

% Draw eyes and mouth with black circles and lines
hold on;
viscircles([-0.25 1.2], 0.1, 'Color', 'black', 'LineWidth', 2);
viscircles([0.25 1.2], 0.1, 'Color', 'black', 'LineWidth', 2);
plot([-0.3 0.3], [0.8 0.8], 'Color', 'black', 'LineWidth', 4);
plot([0 -0.3], [0.2 0.8], 'Color', 'black', 'LineWidth', 4);
plot([0 0.3], [0.2 0.8], 'Color', 'black', 'LineWidth', 4);

% Add some text and axis properties
text(0, -1.5, 'Happy Halloween!', 'HorizontalAlignment', 'center',...
    'FontSize', 16, 'Color', 'black');
axis equal;
axis([-2 2 -2 3]);
box off;
768 chars
23 lines

This code will draw a pumpkin shape with orange color filling, black eyes and mouth, and some text on the bottom. You can modify the x and y coordinates to adjust the shape and size of the pumpkin, and customize the colors and line properties as desired.

gistlibby LogSnag