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

1 visualización (últimos 30 días)
KLETECH MOTORSPORTS
KLETECH MOTORSPORTS el 24 de Nov. de 2020
Respondida: Ameer Hamza el 24 de Nov. de 2020
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

Respuestas (1)

Ameer Hamza
Ameer Hamza el 24 de Nov. de 2020
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.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by