Hi, so i am new to Matlab and I am trying to do an assignment that solves for an unknown mass in a elastic collision. Everytime I run the equation that I have derived, I get the error "Index exceeds number of array elements (1)" on the line solving for m1. Any solution would be appreciated, thanks so much.
clear % clears all variables in the Workspace, avoids common errors
% ----- given information -----
m2 = 150; % mass of car 2, in g
v1i = 30; % initial velocity of car 1, in cm/s
v2i = -30; % initial velocity of car 2, in cm/s
v1f = 0; % the final velocity wanted for car 1 after collision, in cm/s
% ----- calculations -----
m1 = m2(v1i + v1f - 2 * v2i) / (v1i - v1f) % mass of first car, derived
% from equation on paper
M = m1+m2 % total mass of both cars, in g
Best Answer