Skip to content

Instantly share code, notes, and snippets.

@sg-s
Last active August 29, 2015 14:05
Show Gist options
  • Save sg-s/af7d6d120275baba0665 to your computer and use it in GitHub Desktop.
Save sg-s/af7d6d120275baba0665 to your computer and use it in GitHub Desktop.
Handy hashing for PDFs made by MATLAB code

Automatic Version control for publish()

MATLAB's publish takes a script and makes a PDF from it. Here, we want to add some basic info about the file that created the PDF to the PDF, programatically.

Add the name of the file that created the PDF to the PDF

add this snippet of code to the bottom of the script that you will publish with MATLAB's publish() function (or my MakePDF.m wrapper)



%% Version Info
% The file that generated this document is called:
disp(mfilename)

Add the hash of the file that created the PDF to the PDF

%%
% and its md5 hash is:
Opt.Input = 'file';
disp(DataHash(strcat(mfilename,'.m'),Opt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment