How to extract figure data in MATLAB

Recently, I had to deal with a set of data, some from experiments, and some obtained using MATLAB “Curve Fitting Tool”. As much as I like MATLAB figures, I usually find Excel features more desirable for good-looking plots! So, I needed to extract the data of Curve Fitting Tool. Here is what I did:

Save the figure as a “.fig” file.

Make a m-file with the following code to get the x, y data of the curve!

Then you have access to the data, and you can get the arrays as

Then, your data is ready to copy/export to Excel.

1 comment

  1. Hi, this is an excellent post which truly saved me a lot of time. I just want to add however that when you have multiple plots (in my case, 4) in the figure, then the indexing seems to be the reverse of what you say. For example, in order to get the y-values of the third plot/line, I use the curly braces like this: {3, 1} and not {1, 3}. This is perhaps a consequence of how the other person saved her plots, I don’t know.

    Kheeli mamnoun!

Leave a Reply