Reputation: 55
I need to find the maximum of a Gaussian I have fitted, below is my sample code (ignore the fact that it is a horrible fit to the Gaussian, they were just two spare matrices I had kicking around in my variables tray)
x=[10;2;6;1;7;5;3;4;8;9];
z1=[0;0;0;0;0;6;7;8;9;10];
cf1=fit(x,z1,'gauss1');
plot(x,z1,'.k')
hold on
plot(cf1,'r')
Any help you guys could give me would be greatly appreciated.
Upvotes: 0
Views: 4079
Reputation: 38042
That's pretty basic math. Look at the output of
>> cf1
cf1 =
General model Gauss1:
cf1(x) = a1*exp(-((x-b1)/c1)^2)
Coefficients (with 95% confidence bounds):
a1 = 5.187 (-0.4711, 10.85)
b1 = 6.834 (-0.768, 14.44)
c1 = 5.945 (-8.833, 20.72)
Now, armed with the wikipedia article on Gaussians, it's trivial to find the maximum:
maximum_x = cf1.b1;
maximum_y = cf1.a1;
Same will be true for whatever other tool you use to fit the same function -- the coefficients a1
and b1
define the y
and x
locations of the maximum, respectively.
Upvotes: 3