i fit a second order polynomial to this using polyfit and
find the coeficients in descending order.
now i want to find the 'minimum value' of 'y' and its site
with respect to x i.e. in this data y minimum is (142)
which is at x=5 but infact the polynomial may be reaching a
further minimum value between x=5 and 6 say 5.2145 etc...
how to find such a value of x at which the polynomial is
minimum using the above polynomial????
or
is there another method to find a quadratic function which
fits the above data and which i can solve easily to find
minval and minsite???
I tried 'fnmin' which requires spline/cubic fit but i did
not succeed in getting minimum value
this is what i did:
fun=spline(X,[0 Y 0]);
[minval minsite]= fnmin(fun, X); %interval-X
for the actual data that i have (not the above one) i got
minsite = 2 which was not the site for minval. the min
value was at x=13 and i wanted further refinement in x...
what could be the solution???
Why would fitting a spline necessarily
reproduce the shape and location of the
minimum of the least squares quadratic
polynomial?
You have the quadratic polynomial.
What do you know about the location
of the minimum of a quadratic?
John
y = a*(x+b/(2*a))^2+c-b^2/(4*a)
Hence the minimum or maximum always occurs at x = -b/(2*a), according as
the quantity a is positive or negative, respectively, and the value there is
obviously
c-b^2/(4*a)
Roger Stafford
Roger,
thanks for the info ... I am trying to understand what you
have said there.... but not successful yet... let me think
more.
And my point was, that a quadratic
function is trivial to find the minimum of.
Use what you know about mathematics
to solve the trivial problems.
Its not even worth looking for fminbnd,
which would do what you wanted, or
fminsearch, another tool which would
have done it.
> then i tried to fit a spline(cubic curve) to the same data
> because i found a function 'fnmin' which gives me the
> minimum val and its site if i give a spline as input...
> that was the second part of the mail (both mutually
> exclusive events)
> however in this second part i think i made some mistake in
> the syntax and therefore got wrong results and i wanted
> some help on the systax....
Ok, then why not show us what you tried
that failed, instead of fishing around for
someone to give you the answer? fnmin
is perhaps the most trivial function to use
I've ever seen, so show us what you did.
John
i tried the spline fit problem in several ways according
to the info in help and it worked ultimately....painful!
I had given what i tried earlier in my original
post..since the curve fitting was just a small part of the
whole program thats why i dint mail the whole .m file...
fun=spline(X,[0 Y 0]);
minval minsite = fnmin(fun,X) ...this is what i was trying
for which i got starnge results...
then
fun=spline(X,Y);
minval minsite=fnmin(fun,X); ..this worked... how?..dont
know..whats the diff except [ 0 Y 0 ] nemind thanks for
your time.