We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
% Define symbolic variables for time t, and position functions
x(t) and y(t)
syms t x = input('Enter the expression for x(t): ', 's'); % x(t) y = input('Enter the expression for y(t): ', 's'); % y(t) % Convert input strings to symbolic expressions x = str2sym(x); y = str2sym(y);
% Calculate velocity components (derivatives of x and y)
vx = diff(x, t); vy = diff(y, t);
% Calculate the position vector and velocity vector
r = [x; y]; % Position vector r v = [vx; vy]; % Velocity vector v % Calculate the angular momentum (cross product of position and velocity vectors) L = cross([r; 0], [v; 0]); % Extend to 3D for cross product (z=0)
% Simplify angular momentum expression
Lz = simplify(L(3)); % Only z-component is relevant for 2D motion % Plot the trajectory (x vs y)
figure; % Open a new figure window for the graph of x vs y
% Define the time range for plotting
t_vals = linspace(0, 10, 100); % 100 points between t=0 and t=10