- #1

- 1,266

- 11

## Main Question or Discussion Point

I'm trying to solve the following problem using a matlab script but I keep getting an error:

Show on the same axes the maximum height and horizontal distance travelled for an object thrown at a speed of 10ms

D= v

h= (v

g=9.81.

This is my code:

When I run this code the graph doesn't come up and I get the following error:

Show on the same axes the maximum height and horizontal distance travelled for an object thrown at a speed of 10ms

^{-1}at an angle ranging from 0 to π/2. Equation for distance & height are:D= v

^{2}/g sin(2θ)h= (v

^{2}/2g) sin^{2}θg=9.81.

This is my code:

Code:

```
g=9.81; v=10;
t=pi/2;
D=(v^2/g)*sin(2*t);
h=(v^2/(2*g))*(sin(t)).^2;
end
plot([0:t],D,'b',[0:t],y,'*')
legend('horizontal distance','maximum height')
```

Any help here is very much appreciated.??? Error: File: Untitled.m Line: 5 Column: 1

Illegal use of reserved keyword "end".