How to enter a trajectory equation?

조회 수: 3 (최근 30일)
Emily Terwilliger
Emily Terwilliger 2018년 9월 17일
편집: Dimitris Kalogiros 2018년 9월 17일
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
Dimitris Kalogiros 2018년 9월 17일
Do you want to give values to x and calculate corresponding values of y, οr the inverse calculation ?
Emily Terwilliger
Emily Terwilliger 2018년 9월 17일
I'm solving for y. I have the values defined, I just need the equation written correctly

댓글을 달려면 로그인하십시오.

답변 (1개)

Dimitris Kalogiros
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)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by