How to enter a trajectory equation?
3 views (last 30 days)
Show older comments
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
Dimitris Kalogiros
on 17 Sep 2018
Do you want to give values to x and calculate corresponding values of y, οr the inverse calculation ?
Answers (1)
Dimitris Kalogiros
on 17 Sep 2018
Edited: Dimitris Kalogiros
on 17 Sep 2018
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)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!