Extracting Multiple X values for a certain Y value from a plot?

1 回表示 (過去 30 日間)
KLETECH MOTORSPORTS
KLETECH MOTORSPORTS 2020 年 11 月 24 日
回答済み: Ameer Hamza 2020 年 11 月 24 日
I need to find the value of time at all the crests and troughs of the displacement (at displacement =pi/4=0.7854), i.e, Y value is constant
for the following plot (which consists of two curves)
the code i used is:
tspan = 0:0.01:20;
a=pi/4;
b=0;
x0 = [a; b];
[t1,x] = ode45(@pend_l,tspan,x0);
X1 = x(:,1);
X2 = x(:,2);
y0 = [a ; b];
[t2,y] = ode45(@pend_n,tspan,y0);
Y1 = y(:,1);
Y2 = y(:,2);
plot(t1,X1); %linear disp vs time, i.e, red plot
xlabel('Time (s)');
ylabel('Displacement (rad)');
hold on;
grid on;
plot(t2,Y1); %nonlinear disp vs time, i.e, blue plot

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 24 日
See this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections. You can define a straight line at y = constant and find the intersection between the line and your curves.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by