How to print the intersection between two functions?

3 Ansichten (letzte 30 Tage)
ML
ML am 12 Apr. 2019
Beantwortet: darova am 12 Apr. 2019
Here is my code:
% Projectile motion
z0=0;h0=0; tmax=3; t=[0:0.1:1]*tmax;
pr_xdot = @(t,x) ([x(2); -9.81; x(4); 0]);
[tt,zz]=ode45(pr_xdot,t,[z0; v0z; h0; v0h]);
% Distance BC
x=0:0.1:15; y=x*tand(-beta);
plot(zz(:,3), zz(:,1), x, y); grid on; legend ('Projectile','Inclination');
xlabel('Horizontal distance [m]'); y1=ylabel('Vertical distance [m]');
interp1(x,y,pr_xdot)
I'm trying to use interp1 to find the value where the differential equation intersections with the simple x,y linear plot. I then want to print the resulting x and y coordinate. But I'm not having any luck with my interp1 function
Projectile.png

Antworten (1)

darova
darova am 12 Apr. 2019
zz1=interp1(zz(:,3),zz(:,1),x); % if you want to interpolate projectile
mm.png
mm1.png
mm2.png More points - better precision

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by