\graphing witth multiple functions

3 次查看(过去 30 天)
fff

采纳的回答

Shubham Gupta
Shubham Gupta 2019-10-2
编辑:Shubham Gupta 2019-10-2
Try :
a = gca;
hold on
plot(a.XLim,[560, 560],'m--') % plots horizontal line at y = 560
To find the intersection point at y = 560 with the function data ('ydata' for example below)
indx = find((ydata-560).*([ydata(1),ydata(1:end-1)]-560)<0); % finds index corresponding to intersection points
num_of_intersection = length(indx)
xintersect = xdata(indx)
Let me know if there is any doubt
  1 个评论
Shubham Gupta
Shubham Gupta 2019-10-3
编辑:Shubham Gupta 2019-10-3
I am sorry, I forgot to mention that I assumed ydata to be a row vector. So, can you please try to define ydata as a row vector before finding indeces for the intersection? Use:
ydata = Plength(:,3)';

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by