#%% 作者微信:qczsbwjzjn
clear
r = 0.5; % 半径
theta= 0: 0.01: 2*pi; % 弧度
h = 0.05; % 步长
x = 0: h: 4*pi; % 函数定义域
f = sin(0.05*x.*x-1); % 函数值域
k = diff(f)/ h; % 一阶差分求近似一阶导数
x = x(1: end - 1); % 更新定义域
f = f(1: end - 1); % 更新值域
px = x - k*r./sqrt(k.*k+1); % 计算p点横坐标
py = f + r./sqrt(k.*k+1); % 计算p点纵坐标
for i = 1:length(px)
plot(x, f); % 画曲线
hold on
axis([-1.5 14 -2 4]) % 设置坐标轴可视区间
daspect([1 1 1]) % 固定x,y轴
% 画圆
** a = r * sin(theta) + px(i);
b = r * cos(theta) + py(i);
> **
plot(a, b);
hold off
m(:,i) =getframe; % 得到当前帧
end
上面的 ** a = r * sin(theta) + px(i);
b = r * cos(theta) + py(i);
> 是怎样被定义的