% This is a program to perform a lorentz transformation % Written by Don Smith, November 26, 2006 % You may use this file as a starting point, but please rewrite it to % reflect your understanding of what's going on. function[dRp]=Lorentz(beta,dx,dy,dz,cdt) % beta is speed in units of c=1 % dx,dy,dz,cdt are the components of the four vector you wish to transform dR = [dx; dy; dz; j*cdt]; % create a four-vector from the inputs % Define useful quantities gamma =; % If you remove the semi-colon, MatLab will report what it % thinks the value of the variable is. This is useful for debugging, % but very annoying when you are running it. Take out the semi-colons % until you are sure everything is working, and then put them back in. betgam = ; % initialize the lorentz matrix lorm = zeros(4,4,'double'); % Define the non-zero terms in the matrix lorm(1,1) = gamma; % top-left corner dRp = lorm * dR; % multiply matrix times vector (order matters) end % return dRp as answer