How come I can't solve this simple equation?

1 view (last 30 days)
g=9.81;
x0=-1000;
y0=1;
v0=585;
q=10;
w=12;
e=14;
x=0:100:4029.7;
%From the Projectile Motion Equations, I substituted the t value of the x
%component into the y compnonent function. This way I have a graph of
%height(y) as a function of distance(x). Here are the different artillery angle shot
%functions.
yq=(v0*sin(q))*((x-x0)/(v0*cos(q)))+(1/2)*g*((x-x0)/(v0*cos(q)))^2+y0;
%I receive the error:
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is
a scalar. To perform elementwise matrix powers, use '.^'.
Error in MacLab2 (line 24)
yq=(v0*sin(q))*((x-x0)/(v0*cos(q)))+(1/2)*g*((x-x0)/(v0*cos(q)))^2+y0;
%How can I write this code for it to function?

Accepted Answer

Walter Roberson
Walter Roberson on 17 Sep 2018
yq=(v0*sin(q))*((x-x0)/(v0*cos(q)))+(1/2)*g*((x-x0)/(v0*cos(q))).^2+y0;

More Answers (0)

Categories

Find more on Mathematics 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!