How to enter a trajectory equation?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dimitris Kalogiros
2018-9-17
Do you want to give values to x and calculate corresponding values of y, οr the inverse calculation ?
回答(1 个)
Dimitris Kalogiros
2018-9-17
编辑:Dimitris Kalogiros
2018-9-17
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!