How to enter a trajectory equation?

So I have this equation to solve in MATLAB and I'm having trouble writing it. I've written it just as it appears, but it won't run. Can someone please put the correct way to write it? I've been given parameters, but I haven't included them as I'd like to try to solve as much of it as I can by myself. Thank you in advance!!!

3 Comments

Stephan
Stephan on 17 Sep 2018
Edited: Stephan on 17 Sep 2018
Please provide the code you have tried so far by inserting it, marking it and use the {Code} Button.
Do you want to give values to x and calculate corresponding values of y, οr the inverse calculation ?
I'm solving for y. I have the values defined, I just need the equation written correctly

Sign in to comment.

Answers (1)

Here is my suggestion :
clearvars; clc; close all;
% definition of variables
syms x y theta_0 v_0 g y_0
% equation
y=tan(theta_0)*x-(g/(2*v_0^2*cos(theta_0)^2))*x^2+y_0
% values of parameters
u = symunit; % load units
g = 9.81 * u.m/u.s^2 ;
theta_0 = pi/4 * u.rad;
v_0 = 10 * u.m/u.s;
y_0 = 1 * u.m;
% give value of x and calculate coresponding y value
x=2 * u.m % value of x
y=subs(y) % calculate value of y
y=vpa(y) % variable precision representation
I use symbolic math toolbox, and I also include units.
If you run this piece of code through a live script, you will get this :
(I gave values to all parameters, in order to complete calculations)

Asked:

on 17 Sep 2018

Edited:

on 17 Sep 2018

Community Treasure Hunt

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

Start Hunting!