How to find a intersecting point in a GUI?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I've made a app which plots a projectile motion and a fixed line at y=2. See figure below.
I wish to mark the intersection point, and show the x-coordinate. Unfortunatly I don't know how.
My question is, how can I mark the intersecting point (and preferably show its x-coordinate)?
I've included the code to make te plot.
greetings,
Ries
% Button pushed function: PlotButton
function PlotButtonPushed(app, event)
%formula and variables
x0 = 0;
y0= app.Y_0EditField.Value;
v=app.VmsEditField.Value;
angle=app.AngledegEditField.Value*(pi./180);
g=9.81;
t= 0:0.0001:3;
x=x0+v*cos(angle)*t;
y=y0+v*sin(angle)*t-(g*t.^2)/2;
%Hold when 'hold'button is pressed
if app.holdButton.Value==0
hold(app.UIAxes, 'off')
else
hold(app.UIAxes, 'on')
end
%plot graph on GUI
plot(app.UIAxes,x,y)
yline(app.UIAxes,2);
%axis appearance
app.UIAxes.XMinorGrid = 'on'
app.UIAxes.YMinorGrid = 'on'
app.UIAxes.XGrid = 'on'
app.UIAxes.YGrid = 'on'
app.UIAxes.XLim = [0 4];
app.UIAxes.YLim = [0 6];
end
0 Commenti
Risposte (1)
Adam Danz
il 17 Gen 2020
Modificato: Adam Danz
il 20 Gen 2020
You can provide the (x,y) coordinates of the two lines and it will provide the intersection point.
"how can I mark the intersecting point (and preferably show its x-coordinate)"
hold on
plot(x0,y0,'m*')
or
xline(x0,'-k','xIntersection')
yline(y0,'-k','yIntersection')
0 Commenti
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!