piirrä joulukuusi in matlab

main.m
% Create a figure
figure;

% Define the shape of the tree
tree_height = 10;
tree_width = 15;

% Plot the tree
for i = 1:tree_height
    plot([tree_width/2-i:tree_width/2+i], i*ones(1, 2*i+1), 'g');
    hold on;
end

% Plot the tree trunk
trunk_width = 3;
trunk_height = 2;
trunk_position = tree_height + 1;
plot([tree_width/2-trunk_width/2, tree_width/2+trunk_width/2, tree_width/2+trunk_width/2, tree_width/2-trunk_width/2, tree_width/2-trunk_width/2], [trunk_position, trunk_position, trunk_position+trunk_height, trunk_position+trunk_height, trunk_position], 'k');

title('Christmas Tree');

axis off;
605 chars
23 lines

This code will create a simple Christmas tree in MATLAB with a specified height, width, trunk height, and trunk width.

related categories

gistlibby LogSnag