Skip to content

Instantly share code, notes, and snippets.

@Kappie
Created April 18, 2017 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kappie/15b0b8eb88a9b465fe2bac75c4257bab to your computer and use it in GitHub Desktop.
Save Kappie/15b0b8eb88a9b465fe2bac75c4257bab to your computer and use it in GitHub Desktop.
store_data_of_current_fig_to_file.m
function store_data_of_current_fig_to_file(filename)
% Get data vectors of current figure
lines = findobj(gca,'Type','line')
file_id = fopen(filename, 'w');
for line = lines'
x = line.XData;
y = line.YData;
fprintf(file_id, '%3f %3f\n', [x; y]);
% Write two blank lines for gnuplot to recognize the next plot as separate.
fprintf(file_id, '\n\n');
end
fclose(file_id);
type(filename)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment