Skip to content

Instantly share code, notes, and snippets.

@mvanzulli
Last active April 1, 2022 04:54
Show Gist options
  • Save mvanzulli/59227c63f5fb76c9556630f96380a3ab to your computer and use it in GitHub Desktop.
Save mvanzulli/59227c63f5fb76c9556630f96380a3ab to your computer and use it in GitHub Desktop.
Function to create a .tex latex input exporting codes parameters
function [] = texDataGenSDCantBeam( printParams, example )
%Compute output directory
texFolderPath = ['./../../../tex/'];
%Name of the file
nameExampleFileVals = ['valsExample' num2str(example) ];
% Write values of the example
% open file
exampleTexFile = fopen( [ texFolderPath nameExampleFileVals '.tex' ] ,'w') ;
% introduce example name
problemName = 'exampleName';
% Read print params list
paramNames = fieldnames(printParams) ;
for paramIndex = 1:length( paramNames )
nameParam = paramNames{ paramIndex } ;
valueParam = getfield(printParams, nameParam) ;
fprintf(exampleTexFile, [ '\\newcommand{\\' problemName nameParam '}{' num2str(valueParam) '}' '\n' ] ) ;
end
% close file
fclose(exampleTexFile);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment