centering a graph at the origin point

10 views (last 30 days)
Holden Earl
Holden Earl on 17 Apr 2020
Edited: darova on 17 Apr 2020
all of my graphs for some reason will start at some arbitrary number like 300 and not show my graph. the one i am trying to plot is kind of complex so i tried it with a simple line and it still wouldnt work but this is the code im trying to plot.(there might be a mistake with my code but even the simple plots wont work )
v0 = (125/3.6);
g = 9.81;
t = 7.4535;
h = 60.4972;
theta = (pi/0.1944);
x = v0*t*cos(theta);
y = h - ((g*t.^2)*1/2)+(v0*t*sin(theta));
plot(x,y);
  2 Comments
Tommy
Tommy on 17 Apr 2020
Edited: Tommy on 17 Apr 2020
Every variable in your code is a scalar, including x and y. When you call plot using scalars, no line will be plotted, and you will only see the value if you specify a marker, like 'o':
v0 = (125/3.6);
g = 9.81;
t = 7.4535;
h = 60.4972;
theta = (pi/0.1944);
x = v0*t*cos(theta);
y = h - ((g*t.^2)*1/2)+(v0*t*sin(theta));
plot(x,y,'o');
To plot a line, x and y need to contain multiple elements. For example,
v0 = (125/3.6);
g = 9.81;
t = linspace(1,7.4535,100);
h = 60.4972;
theta = (pi/0.1944);
x = v0*t*cos(theta);
y = h - ((g*t.^2)*1/2)+(v0*t*sin(theta));
plot(x,y);
Holden Earl
Holden Earl on 17 Apr 2020
ahhh okay thanks, you're a lifesaver!

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!