Skip to content

Instantly share code, notes, and snippets.

@krantikal
Created March 31, 2021 11:41
Show Gist options
  • Save krantikal/a52e600e889082008f6704f7ea9eea87 to your computer and use it in GitHub Desktop.
Save krantikal/a52e600e889082008f6704f7ea9eea87 to your computer and use it in GitHub Desktop.
[Relativistic velocity addition] #demo #sample Matlab #script file used in #astrophysics #coursework
% Script : rvel.m
% Graph demonstrating the velocity addition formula
% Easily convertible to a Live Script
% Create basic plot
beta=0:0.02:1;
rv1=2*beta;
rv2=rv1./(1+beta.*beta);
rvel_limit=ones(size(beta));
Traces=plot(beta,rv1,beta,rv2,beta,rvel_limit);
% Annotate the plot
xlabel('\beta');
ylabel('\beta_{relative}');
legend('Classical','STR');
title('Velocity Addition Formula');
% Modify the Traces
set(Traces(1),'linewidth',2)
set(Traces(2),'linewidth',2)
set(Traces(3),'linestyle','--')
% Set button for printing in color
uicontrol('string','Print in Color','pos',[10 20 100 20], ...
'call','print -dwinc');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment