Extracting Multiple X values for a certain Y value from a plot?
3 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!