fminsearch with three parameters

I'm trying to do an fminsearch on a function with three free variables and I get the following message :
??? Attempted to access p(3); index out of bounds because numel(p)=2.

Error in ==> @(p)lorfit(Table1,p(1),p(2),p(3))


Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});

here's the code for my function lorfit :
function [ ansa ] = lorfit(x,G,x0,H)
ansa = 0;
for c = 1:length(x)
ansa = ansa + (x(c,2) - (H/(2*((x(c,1)-x0)^2+(G/2)^2))))^2;
end
ansa = sqrt(ansa);

end

Can someone tell me what I'm doing wrong?
0
Bob
1/19/2011 9:14:05 PM
comp.soft-sys.matlab 206975 articles. 0 followers. lunamoonmoon (258) is leader. Post Follow

1 Replies
603 Views

Similar Articles

[PageSpeed] 48
On 1/19/2011 4:14 PM, Bob Garrett wrote:
> I'm trying to do an fminsearch on a function with three free variables
> and I get the following message :
> ??? Attempted to access p(3); index out of bounds because numel(p)=2.
>
> Error in ==> @(p)lorfit(Table1,p(1),p(2),p(3))

> Can someone tell me what I'm doing wrong?

Whatever code is calling FMINSEARCH is apparently calling it with a 
starting vector that has fewer than three elements.  Set a breakpoint at 
that line of code, run it, and see what's being passed in.

Hope this helps.
0
Peter
1/20/2011 2:26:36 PM
Reply:
Similar Artilces:

fminsearch
Hallo, Der Versuch mein Programm "ITS_90_converter2(2,'S',1e-2,3e-5,4e-6)"  in Mathscript laufen zu lassen scheitert. Ich denke fminsearch findet die zu minimierende Funktion (myfun2) nicht, oder liegt der Fehler wo anders. Coefficients und Coefficients_invers2 liefern keine Probleme. Oftmals h�ngt sich die Software auch auf und muss neu gestartet werden! Eingabe Parameter wie oben, Matlab antwortet:ans =  273.9756F�r ein Tipp w�re ich sehr Dankbar! Ausserdem: lassen sich global's eleganter schreiben, als ich das getan habe?Gr�sse ni2.7z: http...

Vista Home Premium- Three and half months later
For a while, I wanted to try Vista on my home PC but few things were holding me back. I had heard there were no Vista drivers for my Canon scanner. The OS was a bit too expensive and finally the whole EAX-Alchemy support (or the lack of) for Audigy2 had left me a bit unintrested. Then two things happened that made me try the new OS. The local Frys Electronics started selling a 300GB SATA2 hard-disk for $69 - a perfect way to try out Vista by setting up a dual boot. Secondly, I found out that pretty much any version of Vista can be installed without having a valid key and be tried for four mont...

template object as a template parameter ?
Hi guys, i give up finding a solution by reading or by trial & error. Hope, YOU can help me! (Sorry for my rather long posting.) Stroustrup says, that templates could be declared with - type parameter, e.g. template<class T> - parameters with *simple* types like int, e.g. template<int size> - template parameter, e.g. template< template<class> class A > the latter beeing a type specifier, not an instance of A. So, there is no way to declare a template class with an *object* of my own (template) class A ?? I want to declare a template class giving it ...

Re: length of the macro parameter #2
On Fri, 13 Jun 2008 06:01:39 -0400, SUBSCRIBE SAS-L Anonymous <g.galiazzo@CRIF.COM> wrote: >Hi to everybody. >My problem is that I need to pass a string as parameter list of a macro >longer than 239 chars with sas v8... >As example: > >%macro mymacro(parm1= [................ 300 char ], > parm2 = hello); > > >...for the first parm1 with SAS v8 the macro will fetch only 239 chars >from the string. >Somehow this problem has bees resolved for version 9, because the string >is passed correctly running the macro in SAS v9. hi, if it is po...

fminsearch and bounded variables
Hi, I have to minimize a function w.r.t. certain parameters, but the parameters themselves are bounded and assume values from a set of intervals. Is it possible to incorporate it in ordinary minimizer, something like fminsearch or gradient based methods? I may try to make value of function infinite when the parameters are outside the range, but I don't know how the minimizer would perform given then the function would no longer be continuous/differentiable. Thanks Chris ...

Inheritance between three classes
Hi, a very simple question. I am trying to understand inheritance using c++ and dont cee how i could use three classes to create an accounting program using inheritance. e.g one class containing members for both, and then a class for checking accounts and a class for savings. Finally could you just clarify that this is the correct use of i nheritance because i am thoroughly confused. "Wilson" <tpwils@googlemail.com> wrote in message news:1172426760.794081.185490@q2g2000cwa.googlegroups.com... > Hi, a very simple question. I am trying to understand inheritance > using c...

Re: Three Texas Men With Cellphones Arrested ... #2
Neal McLain wrote: > nospam4me@mytrashmail.com (Herb Oxley) wrote: >> Wal-mart leaves as little as possible to cashier discretion; for >> example a cashier is prompted to "verify age" when they scan in an >> age-restricted product such as alcohol, tobacco or M-rated [1] >> videogames. > Or even Liquid Nails! More and more companies will do this. Not doing so and having a cashier make an "illegal" sale opens you up to a lawsuit in this country. If you watch TV after midnight, you'll see multiple ads per hour prompting you t...

SN#20692 Red Hat Enterprise Linux 5.1, One- and Three-Year Premium Subscription
SYSTEM NEWS FOR SUN USERS Vol 128 Issue 2 2008-10-10 Article 20692 from section "Service" Background Information and Links Red Hat Enterprise Linux 5.1 provides the latest open source software technologies, which are designed to offer improved performance, security, flexibility and introduce integrated virtualization capabilities for operating systems and data. Sun offers a selection of x64-based systems certified for Red Hat Enterprise Linux. Details at http://sun.systemnews.com/g?A=20692 Have a custom version of 'System News ...

pdepe under fminsearch
Hi! I have this math model, with witch I have to describe the experiment. I have to find model constants. So I optimize my model, until Standard deviation of experimental and model data is less then 10e-04. Model data is calculated from a system of 2 part diff equation. So I use pdepe, which is solved under fminsearch. I have a function that looks like this: k = fminsearch(@SD, k0); k ... parametar I have to optimize SD ... Standard deviation function @SD looks like: function y = SD(k) y is gained from Experimantal vaues and Math model values math model values are gained from system of 2 pa...

Disassembling strings and turning them into function parameters
Hi, I'm pretty new to Python, to programming overall...so how would I make something where the user inputs multiple words in a string - like "connect 123.123.123.123 21 user password" or similar, and then I can split this string up to pass these arguments to a function like ftp_connect(ip, port, user, pw) etc...? I have no idea how to "break" the string up so I can get these out of it.. thanks for answers, munin mercuryprey@gmail.com wrote: > Hi, > I'm pretty new to Python, to programming overall...so how would I make > something where the user inputs m...

Not used parameter: how to disable the warning
Is there a universal method (valid for all C compilers) that avoids the compiler to generate a warning about a not used parameter of a function? I think it isn't because compiler warnings aren't regulated by the standard. So I'm wondering what could be the best or the better methods to face this situation. I tried with the following on my compiler: int sum(int a, int b, int unused) { unused; return a + b; } but it works only with a low level of warnings. Otherwise I can do: int sum(int a, int b, int unused) { unused = unused; return a + b; } ...

Parameters
Hello guys, I need some help. I need to check the parameters in Sybase database. Are they as recommended. How can I check this? If I need to change them how do I do it? I will really appriciate your help. Recommend to set the following parameters in the Sybase database server to the values specified below: number of locks: 50000 (at least) page lock promotion HWM: 3000 page lock promotion LWM: 3000 number of aux scan descriptors: 400 stack size: 92160 Thank you /Jo sp_conf...

fminsearch with simultaneous equations
Hi, I would like to know if how would fimisearch work with a set of simultaneous equations, for example: function w=something(...) S=fminsearch(@nonlinear,x0) function F = nonlinear(x,a,b,a1,b1,A,B) F =- [ a*x(1) + b*x(2) - A a1*x(1).^2 +c - B] would it minimize the two lines of F simultaneously?? What if wanted to minimize only the first line and use the second one as a restriction? The problem is that I want to minize a function that has a variable that is defined in another function that has endogeneity problems. I would really appreciate if anyone cou...

how to finish first three columns of a matrix
am having matrix A of about 2000 rows like following A = 0 1 1 0 1 0 0 0 0 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 I want to make a new matrib B in which first three columns are finished and last three columns stay there like this B = 0 1 0 1 1 1 0 1 1 1 1 1 kindly help me in matlab B = A(:,4:end) I think I'm not sure what you mean by finished This says grab all rows from the 4th through the last column ...

Coeff of Variation
hi I have 2 data sets Y1 and Y2 and I need to fit the data in Y1 to the function y1 and data in Y2 to fn y2. y1 is a function depending on parameters:a,b,c,d and a variable x y2 is a function depending on parameters:a,b,c,d,e and a variable x I have used minsearch to estimate the parameters a,b,c,d,e. Any idea of how I can obtain the coefficient of variation of each parameter and also the correlation matrix? Once you have defined your cost functional, which I would assume is some sort of least squares, you could either try deriving the gradient if it's differentiable, or try estimating...

what is the meaning of these "iptables parameters"?
iptables -F iptables -X iptables -t nat -F -F, -X, -t nat, -F thanks! On Mon, 21 Nov 2005 08:29:57 +0800, nick <i141802596@yahoo.com> wrote: > iptables -F > iptables -X > iptables -t nat -F > > -F, -X, -t nat, -F > > thanks! man iptables -- Reality is just a crutch for people who can't handle science fiction. On Mon, 21 Nov 2005 08:29:57 +0800, nick wrote: > iptables -F Flush all rules > iptables -X Delete all chains Take a look here: http://iptables-tutorial.frozentux.net/iptables-tutorial.html -- Regards Robert Smile... it increases ...

SN#19448 The Three Databases of SXDE 1/08
SYSTEM NEWS FOR SUN USERS Vol 120 Issue 3 2008-02-18 Article 19448 from section "Free and Open Source Software" Which Database to Use for Which Applications The Solaris Express Developer Edition (SXDE) 1/08 offers three different databases - PostgreSQL, MySQL, and JavaDB - all of which are optimized for the Solaris Operating System (Solaris OS). The question is which is the right one to use for which applications. Details at http://sun.systemnews.com/g?A=19448 Have a custom version of 'System News for Sun Users' delivered to you ...

Three questions:VCxBULK, propagation delay,and timing clock.
Hi all, Now I need some help. First I want to know a term:VCxBULK. For example, VC12BULK in STM-1. I think it is a whole payload area of STM-1which is filled with VC12. And its rate is equal to 155M. Other payloads as VC11BULK,VC3BULK,VC4BULK are the same rate as VC12BULK,155M. The difference between them is mapping structure only. What kind of testing or situation will use these payloads? You konw, in the most often testing, we use STM1/VC4BULK to test STM-1 interface. What purpose will use 1.5M,VC11BULK,2M,VC12BULK...? Next is about propagation delay.Is there any recommendation or specific...

signum fminsearch
Hi there, syms x y s m a If I get to have an expression (a function f(x,y,s,m,a)) that involves an integral. The solution of the integral includes the expression 'signum(s)' for example. Then I would like to minimize f(x,y,s,m,a) to its five symbolic variables with the fminsearch function, but the expression "signum(s)" becomes a problem in the fminsearch function. I am using myfun=@(g).... I am entering "signum(s)" as "signum(g(3)) OUTPUT: ??? Undefined function or method 'signum' for input arguments of type 'double'. Could any...

Passing a parameter to a thread (boost)
Hi, I create my threads like this: for(int j = 0; j < 5; j++) { boost::thread *thr = new boost::thread(worker_func); threads.add_thread(thr); } How would i go about passing a parameter into the worker function? If possible i would like to pass a structure in. Thanks for any help, Jack * JackC: > > I create my threads like this: > > for(int j = 0; j < 5; j++) > { > boost::thread *thr = new boost::thread(worker_func); > threads.add_thread(thr); > } > > How would i go about passing a parameter into the worker function? If &g...

function with parameters of function
Hi there, I'm studying dynamic data structure (simple & double linked list, heap, cola, tree, etc) but the teacher obviated the namespaces and others declarations that I don't know their names, old students call it demons inside functions. I'm writing here hoping for you can help me. I've downloaded a tuto where is explained what are the namespace, so, I don't have doubts about it. The other thing is something like a function with parameters of function (called demons), here, I write you the classes declaration that he wrote on the blackboard, unfortunately he didn&#...

fminsearch problems
I have a function findv which is a function of variable U, f and a bunch of others. (It's complicated and calls on several other functions, but trust me, it works) I am trying to fit this function to my data ie, to find the U and f which minimize the sum of the squares of the error, ssq. function variance=ssq(U,f) variance=((Findv(U,f,[0 0 0 0 0 1],... [0 0 0 0 0 0],exp(-.82),6)-5.5)^2+... (Findv(U,f,[0 0 0 0 0 1],[0 0 0 0 0 0]... ,exp(-2.1),6)-4.4)^2); I havetested ssq at my start values and it works. When I run fminsearch I get the error message: ??? Input argument 'f' is u...

Three PhD positions in self-adaptive systems at Linnaeus University (Sweden)
Three PhD positions in software engineering of self-adaptive systems at Lin= naeus University Sweden [Apologies if you receive multiple postings of this announcement.] The AdaptWise research group that is based at the Computer Science Departme= nt of Linnaeus University, V=E4xj=F6 Campus invites applications for three = fully funded PhD positions starting Spring 2014. DESCRIPTION OF POSITIONS ---------------------------------------- 1. Assurances for decentralized self-adaptive systems=20 The goal of the research is to study and develop a formally founded approac= h to provide as...

Stephen Wolfram's book, "A New Kind of Science" gives us three (3) very important facts:
Stephen Wolfram's book, "A New Kind of Science" gives us three (3) very important facts: 1. Mathematics can only explain simple things. 2. You need a model to explain complicated things. 3. But - a simple model can explain complicated things. It looks to me like we have a PHASE model here. "in phase attract" Type those three words - above - into Google (Include quote marks) to learn not only the basics of electricity but how all the fundamental forces work. Or click the following link that will give you the same page in Google. http://www.google...

Q: processing of optional parameters (#rest) ?
Dear all, i have a procedure called fget which is inteded to take a list of optional parameters. It re formates the optional parameters and passed them to fd-execute which in turn takes these parameters as an input. What happens is that the fd-execute sees in his optional parameters the following vector #[#["@3ff031ad/7e820 ", "|DATA|", "|DATA|"]] which does not represents only a single aregument passed to fd-execute, not the arguments for a call like fd-execute( con, "fget", @3ff031ad/7e820 ", "|DATA|", "|DATA|&...