How to make axis continuous based on input
Show older comments
Hi, ive written a code based on projectile motion, and created a GUI with the intent to create an app as a project for university. The issue I run into is my x axis is pre-defined, I was wondering is there a way to change it to where it constantly increased until the line reaches zero in the y-direction, e.g. (6,0) or (58.53,0). In the code below the main block will be in the button callback section. The code below is just the script I use to test, as the forum did not let me post the GUI but its the same without the restrictions.
Thanks in advance!
%======================================================================%
%Arrow is fired from a cliff plot its projectile motion 10m above ground at
%20 m/s
%======================================================================%
clear all %clears workspace
%angle = 0.4; %Size of angle it is fired at in radians from cliff
V0 = 20; %inital velocity = 20 m/s
g = -9.81; %Gravity force taking up as +ive
t = 0:0.1:4; %time
%t = zeros(30);
%h = 10; %height
%Ax = 0; %Vertical Acceleration
Ay = g; %Horizontal Acceleration
%======================================================================%
%xVelocity = V0 * cos(angle);
yVelocity = V0 * sin(angle); %Vertical Velocity
x = t; %x axis = time
y = h + (yVelocity * t + (1/2) * Ay * t.^2); %s = ut + (0.5)at^2
y = max(0,y);
%======================================================================%
plot(x, y);%+10 BECAUSE 10M ABOVE GROUND
%%%%ADD IN LOOP TO STOP WHEN Y AXIS GOES BELOW ZERO THEN INCREASE
%%%%INCREMENTS
%======================================================================%
caption = sprintf('Angle = %.2f radians', angle); %Title of graph defined
title(caption, 'FontSize', 15); %Title of graph inserted
grid on; %Grid on graph
%======================================================================%
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
%======================================================================%
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!