```Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: fminsearch and functions
Date: Fri, 1 Feb 2013 10:24:08 +0000 (UTC)
Lines: 21
Message-ID: <keg548\$gp\$1@newscl01ah.mathworks.com>
References: <kee7p4\$iju\$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1359714248 537 172.30.248.37 (1 Feb 2013 10:24:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 1 Feb 2013 10:24:08 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:787912

Are you sure about the formulation you've posted here. It looks like you are trying to solve a very simple geometrical problem, but the placement of the sqrt and sums makes it a bit odd.

What is it you want to do? You have 10000 points in 2D, and you want to find a point (xc,yc) such that what is minimized? Minimize total Euclidean distance - average distance?

"Robert Ahrens" wrote in message <kee7p4\$iju\$1@newscl01ah.mathworks.com>...
> I should preface this post by saying that I have never used fminsearch for multivariable functions and I am not a heavy user of anonymous functions.
>
> I have defined a function myfun2:
>
> function f = myfun2(x,y,xc,yc)
>
>     n = length(x)
>     f = sqrt((sum((sqrt((xc - x).^2 + (yc - y).^2) - ...
>          sum(sqrt((xc - x).^2 + (yc - y).^2)/n)).^2)/n))
> end
>
> where x and y are vectors (of length upwards of 10,000) and xc and yc are scalars.  Basically, I have known x and y vectors and I want to find xc and yc such that f is minimized. I've read through the fminsearch documentation and posts on the Matlab newgroups and I have not been able to find any information as to how to do so.
>
> Any and all help is appreciated.
> Bob
```