MATLAB
```matlab
% 清除之前的变量和图形
clear all;
close all;
clc;
% 创建一个图形窗口
figure;
% 绘制猪头的外轮廓
theta = linspace(0, 2*pi, 100);
x = cos(theta);
y = sin(theta);
plot(x, y, 'k', 'LineWidth', 2);
hold on;
% 绘制猪头的眼睛
eye_radius = 0.1;
eye_offset = 0.3;
eye_x1 = eye_offset + eye_radius * cos(theta);
eye_y1 = eye_radius * sin(theta) + 0.3;
eye_x2 = -eye_offset + eye_radius * cos(theta);
eye_y2 = eye_radius * sin(theta) + 0.3;
plot(eye_x1, eye_y1, 'r', 'LineWidth', 2);
plot(eye_x2, eye_y2, 'r', 'LineWidth', 2);
% 绘制猪头的鼻子
nose_radius = 0.2;
nose_x = nose_radius;
plot(nose_x, 0.3, 'g', 'LineWidth', 2);
hold off;
```
Python (使用turtle库)
```python
import turtle
设置画布和画笔
a = turtle.Screen()
a.setup(width=400, height=300)
a.speed(5)
a.hideturtle()
画脸型
a.penup()
a.goto(-100, 100)
a.pendown()
a.circle(200)
取名字
a.penup()
a.goto(-150, 10)
yourname = a.textinput("请老实回答", "你的名字是?")
name = yourname + "崽崽"
a.pendown()
a.write(name, font=("elephant", 25, "bold"))
画眼睛
a.penup()
a.goto(-200, 0)
a.pendown()
a.circle(25)
a.penup()
a.goto(-200, -14)
a.pendown()
隐藏画笔
a.hideturtle()
结束绘制
a.done()
```
Python (使用matplotlib)
```python
import matplotlib.pyplot as plt
import numpy as np
设置画布和画笔
fig, ax = plt.subplots()
ax.set_xlim(-200, 200)
ax.set_ylim(-200, 200)
绘制猪头的外轮廓
theta = np.linspace(0, 2 * np.pi, 100)
x = np.cos(theta)
y = np.sin(theta)
ax.plot(x, y, 'k', linewidth=2)
绘制猪头的眼睛
eye_radius = 0.1
eye_offset = 0.3
eye_x1 = eye_offset + eye_radius * np.cos(theta)
eye_y1 = eye_radius * np.sin(theta) + 0.3
eye_x2 = -eye_offset + eye_radius * np.cos(theta)
eye_y2 = eye_radius * np.sin(theta) + 0.3
ax.plot(eye_x1, eye_y1, 'r', linewidth=2)
ax.plot(eye_x2, eye_y2, 'r', linewidth=2)
绘制猪头的鼻子
nose_radius = 0.2
nose_x = nose_radius
ax.plot(nose_x, 0.3, 'g', linewidth=2)
显示图像
plt.show()
```
这些代码示例分别使用MATLAB、Python的turtle库和matplotlib库来绘制猪头的形状。你可以根据自己的需求和编程环境选择合适的工具和方法。