How to enter a trajectory equation?

3 visualizaciones (últimos 30 días)
Emily Terwilliger
Emily Terwilliger el 17 de Sept. de 2018
Editada: Dimitris Kalogiros el 17 de Sept. de 2018
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 comentarios
Dimitris Kalogiros
Dimitris Kalogiros el 17 de Sept. de 2018
Do you want to give values to x and calculate corresponding values of y, οr the inverse calculation ?
Emily Terwilliger
Emily Terwilliger el 17 de Sept. de 2018
I'm solving for y. I have the values defined, I just need the equation written correctly

Iniciar sesión para comentar.

Respuestas (1)

Dimitris Kalogiros
Dimitris Kalogiros el 17 de Sept. de 2018
Editada: Dimitris Kalogiros el 17 de Sept. de 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)

Community Treasure Hunt

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

Start Hunting!

Translated by