MATLAB: How to get an equation from an already plotted graph in matlab

graph function

Hello,
I am trying to get an equation (function) from an already plotted graph, please help me with the code.
Any help will be greatly appreciated, am attaching the graph as well.

Best Answer

Just what type of "function" do you seriously expect to get from that?
So 7000 data points with no simple way to describe them, except using an interpolation. This should suffice:
C = get(gca,'children');
spl = pchip(C.XData,C.YData)
spl =
struct with fields:
form: 'pp'
breaks: [1×7000 double]
coefs: [6999×4 double]
pieces: 6999
order: 4
dim: 1
It probably won't be worth much though, because there is no "equation" you can simply extract from a spline.
If you insist on an equation, I'd suggest randn() is roughly as good as anything else.
Related Question