A small function that captures the currently visible data in a matlab line plot and exports to a data file instantly readable with pgfplots in latex. It is based on and needs the reduce_to_width function by Tucker McClure available here:
Its automatically reduces the number of samples to the minimum to reproduce the displayed matlab graph in the pgf axes. Works also with zoomed data. Note that the reduction results depend on the figure width and height.
Jörg Petzold (2021). matfig2pgfdata(filename,m,n) (https://www.mathworks.com/matlabcentral/fileexchange/65987-matfig2pgfdata-filename-m-n), MATLAB Central File Exchange. Retrieved .
This is a nice function to avoid the error message 'TeX capacity exceeded, sorry' that almost everyone has encountered who has plotted larger datasets with the pgfplots package in LaTeX.
Here is a short test and demo program for this function: https://github.com/Magger/matfig2pgfdata_example
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!