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

조회 수: 3 (최근 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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by