【MATLAB】绘制图像并且标注交点

【MATLAB】绘制图像并且标注交点

逢迎诗酒徒
2024-06-25 / 0 评论 / 160 阅读 / 正在检测是否收录...

使用solve函数,解出方程的交点,使用plot函数标记,也可使用text标注

t = 0 : pi/100 : pi;    
x1 = sin(3*t).*cos(t);
y1 = sin(3*t).*sin(t);    
x2 = cos(t);
y2 = 2*x2-0.5;
plot(x1, y1, x2, y2); xlabel('x'); ylabel('y'); grid on;  title('6');
hold on;
syms t x y
eqns = [x == sin(3*t)*cos(t), y == sin(3*t)*sin(t), y == 2*x - 0.5];
sol = solve(eqns, [t x y]);
t_sol = double(sol.t);
x_sol = double(sol.x);
y_sol = double(sol.y);
plot(x_sol, y_sol, 'r*');
hold off;

lxtwpen4.png

0

评论 (0)

取消