matlab求2曲线交点(含参数)
发布网友
发布时间:2022-04-24 21:26
我来回答
共1个回答
热心网友
时间:2023-10-11 18:19
程序代码如下:
clc;clear;close all;
t=0:0.01:pi;
x=sin(3*t).*cos(t);
y1=2*x-0.5;
y2=sin(3*t).*sin(t);
plot(t,y1,t,y2);grid;
delta_y=y1-y2;
% figure;stem(delta_y);
j=1;
for i=1:length(t)-1
if delta_y(i)*delta_y(i+1)<0
position(j)=i+1;
j=j+1;
end
end
hold on;
plot(t(position),y1(position),'ro');
title('两条曲线相交');
xlabel('x');ylabel('y');
h = legend('y1','y2');