f



fminsearch error: "Undefined function or method 'L' for input arguments of type 'double'"

Hi,

I am trying to minimizing the function 'L' below but I keep getting
the error:

?? Undefined function or method 'L' for input arguments of type
'double'

My code is the following:
----------------------------------------------------------------
%seastate = 2000 x 1 vector
%pings = 2000 x 1 vector
%entang = 2000 x 1 vector

x0 = [-1.5 0.3 -0.1 0.001];  %my initial parameters

exponent = @(x0) x0(1) + x0(2).*seastate + x0(3).*pings +
x0(4).*pings.^2;
pi = @(x0) exp(exponent)./(1 + exp(exponent);
oneminuspi = @(x0) 1 - pi(x0);

L = @(x0) -1*log(prod(pi(x0).^(entang).*(oneminuspi(x0)).^(1-
entang)));

params = fminsearch('L', x0)
------------------------------------------------------------------

Can anyone help me?

Thanks
0
Marlene
2/7/2011 5:26:11 PM
comp.soft-sys.matlab 210093 articles. 11 followers. lunamoonmoon (258) is leader. Post Follow

4 Replies
1045 Views

Similar Articles

[PageSpeed] 57


"Marlene" <brito.nen@gmail.com> wrote in message 
news:7efd7b9b-f704-49dd-867f-7f413953fb54@i39g2000prd.googlegroups.com...
> Hi,
>
> I am trying to minimizing the function 'L' below but I keep getting
> the error:
>
> ?? Undefined function or method 'L' for input arguments of type
> 'double'
>
> My code is the following:
> ----------------------------------------------------------------
> %seastate = 2000 x 1 vector
> %pings = 2000 x 1 vector
> %entang = 2000 x 1 vector
>
> x0 = [-1.5 0.3 -0.1 0.001];  %my initial parameters
>
> exponent = @(x0) x0(1) + x0(2).*seastate + x0(3).*pings +
> x0(4).*pings.^2;
> pi = @(x0) exp(exponent)./(1 + exp(exponent);
> oneminuspi = @(x0) 1 - pi(x0);
>
> L = @(x0) -1*log(prod(pi(x0).^(entang).*(oneminuspi(x0)).^(1-
> entang)));
>
> params = fminsearch('L', x0)
> ------------------------------------------------------------------
>
> Can anyone help me?

Do not call FMINSEARCH with the string 'L' but with the function handle L 
directly.

params = fminsearch(L, x0)

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Steven_Lord
2/7/2011 6:00:03 PM
Thanks....but now I get:

??? Undefined function or method 'exp' for input arguments of type
'function_handle'.

Error in ==> @(betas)(exp(exponent))./(1+exp(exponent))

Does this mean that I cannot use the function handle 'exponent' in the
exp function?

0
Marlene
2/7/2011 6:56:44 PM

"Marlene" <brito.nen@gmail.com> wrote in message 
news:a3a12114-fbb8-4115-9fbc-f48ddf258796@m27g2000prj.googlegroups.com...
> Thanks....but now I get:
>
> ??? Undefined function or method 'exp' for input arguments of type
> 'function_handle'.
>
> Error in ==> @(betas)(exp(exponent))./(1+exp(exponent))
>
> Does this mean that I cannot use the function handle 'exponent' in the
> exp function?

You cannot perform any mathematics on a function handle.

You can perform mathematics on the value you receive by evaluating a 
function handle.

In other words:

x = 1:10;
f = @sin;
exp(f) % will error
exp(f(x)) % will work

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Steven_Lord
2/7/2011 7:13:38 PM
That makes sense...Thank you!
0
Marlene
2/8/2011 12:06:55 AM
Reply:

Similar Artilces:

MNRFIT Error "Undefined function or method 'mnrfit' for input arguments of type 'double'"
My data looks like this: Y=[4;4;5;13.....]; (n by 1) X= 1.3 6.9 2.0 3.2 4.2 6.9048 ..... (n by 2) when i used: [B,dev,stats]=mnrfit(x,y,'interactions','off'); The error message appeared : ??? Undefined function or method 'mnrfit' for input arguments of type 'double'. What caused that problem? Also, shall I convert the y into a format of 1,2,3,4,...k, rather than the code number originally assigned for each choice (starting from 4, to 500+. with irregular numbering) Thanks! "Yiyi Wang" <yiyiwang@mail.ute...

?? Undefined function or method 'svd' for input arguments of type 'double' and attributes 'full 3d real'.
can someone help me, i am trying to use the svd function but i got an error message "?? Undefined function or method 'svd' for input arguments of type 'double' and attributes 'full 3d real'." here is the part of the code displaying the error: F=imread(irisFileName); G=im2double(F); %perform singular value decomposition xpattern=svd(G); P=[xpattern' str2num(irisFiles(i).name(1:3))]; T=[T;P]; thanks "ibrahim " <rodeggs@yahoo.com> wrote in message news:kihvjd$78t$1@newscl01ah.mathworks.com... > can someone help me, i am trying to use the svd function but i got an > error message "?? Undefined function or method 'svd' for input arguments > of type 'double' and attributes 'full 3d real'." The SVD is only mathematically defined for 2-D matrices. It is not defined for 3-D arrays. > here is the part of the code displaying the error: > > F=imread(irisFileName); G=im2double(F); > > %perform singular value decomposition xpattern=svd(G); If your image is an RGB image, it will be an M-by-N-by-3 array. What do you expect from taking the SVD of that image? Do you want to take the SVD of each page? Do you want to somehow convert that into a 2-D matrix? *snip* -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com ...

Undefined function or method 'matrix' for input arguments of type 'double'.
I am getting the following error when using ezplot function. "??? Error using ==> inlineeval at 15 Error in inline expression ==> matrix([[6985136208493369347./31721781146654720, 201778265936837851039916484255./26319065107059678116385452266.*exp(76744614141068183./1676094189595642368.*t).*(cosh(1./1676094189595642368.*25469793587654639801302368490143121.^(1./2).*t) - 9786459305061208830677730919987630./1067487785475669358103947936916887413216130693842741.*25469793587654639801302368490143121.^(1./2).*sinh(1./1676094189595642368.*25469793587654639801302368490143121.^(1./2).*t)) ...

Undefined function or method 'lognrnd' for input arguments of type 'double'.
I am trying to draw random numbers from a lognormal distribution, bu when is sepcify the mean, standard deviation and the matrix size, i get the following message Undefined function or method 'lognrnd' for input arguments of type 'double'. i am wondering how would i fix such a problem. Thanks, In article <ef5c20f.-1@webcrossing.raydaftYaTP>, ammal <alanazi@ualberta.ca> wrote: >I am trying to draw random numbers from a lognormal distribution, bu >when is sepcify the mean, standard deviation and the matrix size, i >get the following message > Undefine...

??? Undefined function or method 'triang' for input arguments of type 'double'.
Hi. I'm trying to run a matlab code that used to work, and I get this message: ??? Undefined function or method 'triang' for input arguments of type 'double'. I am using Matlab R2009a. Thanks Hi triang is part of the Signal Processing toolbox so the first thing to need to ensure is that you have this installed. Type ver If the output doesn't contain 'Signal Processing Toolbox' then that's your problem. If you do have the toolbox then we need to check that your path is set correctly. Type path into MATLAB and ensure that the ou...

??? Undefined function or method 'delayseq' for input arguments of type 'double'.
Dear All, I have a vector of length 1000 and I want to delay it by t= 5.2349e-007 when i run my code i get below error. Please help thanks in advance. ??? Undefined function or method 'delayseq' for input arguments of type 'double'. Error in ==> new1 at 22 shifted_data = delayseq(data,5.2349e-007); On 8/30/2015 11:42 AM, Jamil Hayder wrote: > > Dear All, > I have a vector of length 1000 and I want to delay it by t= 5.2349e-007 > when i run my code i get below error. > > Please help thanks in advanc...

??? Undefined function or method 'degrees2dms' for input arguments of type 'double'.
Hi all, I'm trying to get a conversion done it matlab using function degrees2dms. For that, I'm reading a file with decimal lat and lon information. My problem is that I'm always getting the error: ??? Undefined function or method 'degrees2dms' for input arguments of type 'double'. My script is as following: for i=1:size(filenames,1) fid=fopen(filenames(i,:)); D=textscan(fid,'%f %f %f','HeaderLines',1); data=cell2mat(D); lat_dms=degrees2dms(data(:,1)); lon_dms=degrees2dms(data(:,2)); Can someone give me a help...

Undefined function or method 'uniqie' for input arguments of type 'double'
Hi, I'm trying to use the built-in function 'unique' to exclude non-unique values from the column vector 'trix'. However, I got error: "Undefined function or method 'uniqie' for input arguments of type 'double'". How could I update my code?: x1 = [2; 3; 4]; x2 = [5; 6; 7] trix = uniqie([x1; x2]); On Mar 29, 6:30=A0pm, "Liana " <liananapalk...@email.arizona.edu> wrote: > Hi, > > I'm trying to use the built-in function 'unique' to exclude non-unique va= lues from the column vector 'trix'. However, I got ...

Straight line gradient calculation/image analysis error: Undefined function or method 'b' for input arguments of type 'double'
Hi all, I'm attempting to create a coordinate system on an image using two straight lines obtained using 'getline' Here's what I did: filmpic = imread(film); figure, imshow(filmpic) %I drew this as a horizontal line across the picture [a, b] = getline %I drew this as a vertical line across the picture [c, d] = getline this is the gradient of the horizontal line mH = (b(2)-b(1))/(a(2)-a(1)); I then used straight line equations to find the intersection between the two, and took this as the zero point of my coordinate system. It all worked well until I included a loop: for...

Common Error (Undefined function 'awgn' for input arguments of type 'double'.)
Hi,I have a vector of size 1000 and I want to add noise to it but when I use awgn(x,snr) function i get below error.please help. Undefined function 'awgn' for input arguments of type 'double'. Error in task1 (line 55) y3=awgn(x,snr); "Jamil Hayder" <engr.jamilhayder@yahoo.com> wrote in message news:mrpfej$shc$1@newscl01ah.mathworks.com... > Hi,I have a vector of size 1000 and I want to add noise to it but when I > use awgn(x,snr) function i get below error.please help. > > Undefined function 'awgn' for input arguments of...

Undefined function or method 'feeldof1' for input arguments of type 'double' #2
Hi! I am starting to use MATLAB again after a few years without using it and much as been forgotten. I'm having som trouble with this coding i did (with the help with some parcial coding found on a book on finite element), however it keeps giving the same error response: Undefined function or method 'feeldof1' for input arguments of type 'double'. The code is this: nel=5; nnel=2; ndof=1; nnode=6; sdof=nnode*ndof; % gcoord(1)=0.0;gcoord(2)=0.2;gcoord(3)=0.4;gcoord(4)=0.6;gcoord(5)=0.8; gcoord(6)=1.0; % nodes(1,1)=1;nodes(1,2)=2; nodes(2,1)=2;nodes(...

Undefined function or method 'feeldof1' for input arguments of type 'double' #3
Hi! I am starting to use MATLAB again after a few years without using it and much as been forgotten. I'm having som trouble with this coding i did (with the help with some parcial coding found on a book on finite element), however it keeps giving the same error response: Undefined function or method 'feeldof1' for input arguments of type 'double'. The code is this: nel=5; nnel=2; ndof=1; nnode=6; sdof=nnode*ndof; % gcoord(1)=0.0;gcoord(2)=0.2;gcoord(3)=0.4;gcoord(4)=0.6;gcoord(5)=0.8; gcoord(6)=1.0; % nodes(1,1)=1;nodes(1,2)=2; nodes(2,1)=2;nodes(2,2)=3; nodes(3,1)=3;nodes(3,2)=4; nodes(4,1)=4;nodes(4,2)=5; nodes(5,1)=5;nodes(5,2)=6; % acoef=1; bcoef=-3; ccoef=2; % bcdof(1)=1; bcval(1)=0; bcdof(2)=6; bcval(2)=0; % ff=zeros(sdof,1); kk=zeros(sdof,sdof); index=zeros(nnel*ndof,1); % for iel=1:nel nl=nodes(iel,1); nr=nodes(iel,2); xl=gcoord(nl);xr=gcoord(nr); eleng=xr-xl; [index]=feeldof1(iel,nnel,ndof); k=feode2l(acoef,bcoef,ccoef,eleng); f=fef1l(xl,xr); [kk,ff]=feasmbl2(kk,ff,k,f,index); end % [kk,ff]=feaplyc2(kk,ff,bcdof,bcval); % fsol=kk/ff; % c1=0.5/exp(1); c2=0.5*(1+1/exp(1)); for i=1:nnode x=gcoord(i); esol(i)=c1*exp(2*x)+c2*exp(x)+0.5; end % num=1:1:sdof; results=[num' fsol esol']; And the code for the functions used is: function [kk,ff]=feaplyc2(kk,ff,bcdof,bcval) n=length(bcdof); sdof=size(kk); % for i=1:n c=bcdof(i); ...

error msg: Undefined function or method 'test' for input arguments of type 'struct'.
I have function a = test(b) a.b1 = b.a2; a.b2 = b.a1; end I enter >> b.a1 = 1; >> b.a2 = 2; >> test(b) The result is the error msg: Undefined function or method 'test' for input arguments of type 'struct'. Anyone know what this means? (I've used structure as input arg before.) When I type On 3/19/2012 8:44 AM, Harvey Greenberg wrote: > I have > function a = test(b) > a.b1 = b.a2; > a.b2 = b.a1; > end > > I enter >>> b.a1 = 1; >>> b.a2 = 2; >>> test(b) > > The result is the error ms...

how to solve the Undefined function or method 'robot.m' for input arguments of type 'double'.
I am Mechanical engineering student. I had problem my final year project. I need help from Matlab users..my question is.. how to solve Undefined function or method 'robot.m' for input arguments of type 'double'?? what is type 'double' in the simulation diagnostics?? please help me..tq. "Mohd Firdaus " <mfirdausrahim86@yahoo.com> wrote in message <hl0qpi$b29$1@fred.mathworks.com>... > I am Mechanical engineering student. I had problem my final year project. I need help from Matlab users..my question is.. how to solve Undefined function or method...

Undefined function 'dpsel' for input arguments of type 'double'
I am trying a code that uses a mex file dpsel, this gives an error that function is not defined for argument type double. i tried to check "which dpsel" it comes with " 'dpsel' not found. ". then i tried to add the path to matlab although this path was already added. even then it gives the same error.. Any idea? You help means a lot.. ...

Undefined function 'ndsdpvar' for input arguments of type 'double'.
hi i use yalmip and code as follow: [Plant_1_N,Plant_1_T,Plant_1]=xlsread('F:\Second_Stage_Trail.xlsx','Sheet1'); [Plant_2_N,Plant_2_T,Plant_2]=xlsread('F:\Second_Stage_Trail.xlsx','Sheet2'); [Book_Capacity_N,Book_Capacity_T,Book_Capacity]=xlsread('F:\SGM\Second_Stage_Trail.xlsx','Sheet3'); % [Plant_1_N,Plant_1_T,Plant_1]=xlsread('F:\Second_Stage_Trail.xlsx','Sheet4'); % [Plant_2_N,Plant_2_T,Plant_2]=xlsread('F:\Second_Stage_Trail.xlsx','Sheet5'); x = sdpvar(4,2,6,31,'full'); F=set(x>=0); for i=1:4 for c=1:6 F=F+set(sum(x(i,1,c,:))==Plant_1{i,c}); end end for i=1:4 for c=1:6 F=F+set(sum(x(i,2,c,:))==Plant_2{i,c}); end end for j=1:2 for d=1:31 F=F+set(sum(sum(x(:,j,:,d)))<=Book_Capacity{d,j}); end end f=0; solvesdp(F,f); but when i running it it give me a msg : >> Second_Stage_Trail Undefined function 'ndsdpvar' for input arguments of type 'double'. Error in sdpvar (line 127) sys = ndsdpvar(varargin{:}); Error in Second_Stage_Trail (line 8) x = sdpvar(4,2,6,31,'full'); then i ask my friend to run this for me, he did not have the error though he could not get a solution. i do not know where is wrong. but when i try to use cplex to solve the problem, i can get a solution. thanks a lot for help! Are you really using a recent ver...

Undefined function 'leadlag' for input arguments of type 'double'.
I am trying some sample code from here: http://www.mathworks.com/matlabcentral/fileexchange/37932-automated-trading-with-matlab-2012/content/html/Demo2_MA_Rule.html I modified the code just a bit: annualScaling = sqrt(250); leadlag(Close,1,20,annualScaling) I made the proper adjustments, and I can’t tell why I’m getting this error: Undefined function 'leadlag' for input arguments of type 'double'. I guess Matlab is converting the doubles to ints, because your array contains a single int. This has to do with a precision issue. So, I would think that you could Cast it, or force it to be Double, but it still doesn’t work: annualScaling = sqrt(250); double(annualScaling); leadlag(Close,1,20,annualScaling) Undefined function 'leadlag' for input arguments of type 'double'. ...

Undefined function or method 'No' for input arguments of type 'char'.
Hi, I am writing a simple program for my lab and I can't figure out why the code will work in the command window but not from the m-file. It reads out " ??? Undefined function or method 'No' for input arguments of type 'char'. " each time I try to run the m-file. I am pretty sure the it is in the correct directory. Below is my code that I am trying to run from a m-file but works in command window. clear all Vo = 66.15; %[ft/s] theta_o=18*pi()/180; %[rad] Vox=Vo*cos(theta_o); Voy=Vo*sin(theta_o); yo = 10/12; %[ft] xo = 0; %[ft] t=[]; n=1; y=yo; g=32.2; %[ft/s^2] while y > 0 t(n)=(n-1)*.1; y(n)=yo+Voy*t(n)-.5*g*(t(n))^2; x(n)=Vox*t(n); n=1+n; end plot(x,y) axis([0,85,0,8]) I don't remember ever getting this error. "Son Le" <le.s@husky.neu.edu> wrote in message news:ia3360$ps9$1@fred.mathworks.com... > Hi, > > I am writing a simple program for my lab and I can't figure out why the > code will work in the command window but not from the m-file. > > It reads out " ??? Undefined function or method 'No' for input arguments > of type > 'char'. " each time I try to run the m-file. I am pretty sure the it is in > the correct directory. > > Below is my code that I am trying to run from a m-file but works in > command window. I don't see anything obviously wrong with this code. Set an e...

Undefined function or method 'atan2' for input arguments of type 'sym'
I like to run the following lines of code syms theta alpha x y alpha = atan2(y,x) subs(theta, {x y}, {pi/4 pi/4}) theta = diff(alpha, x); But I am getting an error on the second line: ??? Undefined function or method 'atan2' for input arguments of type 'sym'. Any Ideas how to solve this problem? Thanks Markus PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that. On 5 Jan., 10:41, "Markus " <ba...@acin.tuwien.ac.at> wrote: > I like to run the following lines of code > > syms theta alpha x y > alpha = atan2(y,x) > subs(theta, {x y}, {pi/4 pi/4}) > theta = diff(alpha, x); > > But I am getting an error on the second line: > ??? Undefined function or method 'atan2' for input arguments of type 'sym'. > Any Ideas how to solve this problem? > > Thanks > Markus > > PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that. http://www.mathworks.com/matlabcentral/newsreader/view_thread/73889 Best wishes Torsten. On 1/5/2012 3:41 AM, Markus wrote: > I like to run the following lines of code > > syms theta alpha x y > alpha = atan2(y,x) > But I am getting an error on the second line: > ??? Undefined function or method 'atan2' for input arguments of type 'sym'. > Any Ideas how to solve this problem? > But x and y are j...

Undefined function or method 'Bayesian_Estimation_Volatility2' for input arguments of type 'char'
Hi there, When I try to run the M-File: "Bayesian_Estimation_Volatility2" I get the error: ??? Undefined function or method 'Bayesian_Estimation' for input arguments of type 'char'. However I have another file called "Bayesian_Estimation_Volatility" stored on the same path which runs just fine. I am attempting to alter the original file and save it as a different name. Why will it not run? > When I try to run the M-File: "Bayesian_Estimation_Volatility2" I get the error: > > ??? Undefined function or method 'Bayesian_Estimation&#...

Undefined function or method 'intergrate_adaptive_gauss10' for input arguments of type 'function_handle'.
Hey there, i have a file designed to calculate integrals using 10pt Gaussian Quadrature ------------------------------------------------------------ function [res ok] = integrate_adaptive_gauss10(f_handle, a, b, level, accuracy) res = 0; I = gauss10(f_handle, a, b); I_1 = gauss10(f_handle, a, (a + b)/2); I_2 = gauss10(f_handle, (a + b)/2, b); if accuracy<abs(I - (I_1 + I_2)) [I_1, ok] = integrate_adaptive_gauss10(f_handle, a, (a + b)/2 , level, accuracy); if ok == 0 return end [I_2, ok] = integrate_adaptive_gauss10(f_handle, (a + b)/2, b , level, accura...

??? Undefined function or method 'daqregister' for input arguments of type 'char'
I am using the latest release of matlab on an intel iMac running Windows XP in the Bootcamp partition. I am trying to use a USB-6009 daq and I have installed the current NIDaqmx drivers under the data acquisition toolbox 2.16. The problem I am having is running any of the daq commands such as daqregister. I am getting the error ??? Undefined function or method 'daqregister' for input arguments of type 'char' Is this a problem because I am running Matlab under Bootcamp or is there a path that I do not have set right. I am logged it as administrator when I try running these c...

??? Undefined function or method 'imcrop' for input arguments of type 'uint8'.
Ive been using MATLAB for awhile and I installed it on a new lap top of mine and ran an old test file. I am getting this error: ------------------------------------------------------------ ??? Undefined function or method 'imcrop' for input arguments of type 'uint8'. ------------------------------------------------------------ m file looks like: I = imread(filename); I2 = imcrop(I); Normally i'd assume I didnt have the image processing toolbox, but this is the ver information ------------------------------------------------------------------------------------- MATLAB Version 7.10.0.499 (R2010a) MATLAB License Number: 47490 Operating System: Microsoft Windows 7 Version 6.1 (Build 7600) Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode ------------------------------------------------------------------------------------- MATLAB Version 7.10 (R2010a) Simulink Version 7.5 (R2010a) Control System Toolbox Version 8.5 (R2010a) Global Optimization Toolbox Version 3.0 (R2010a) Image Processing Toolbox Version 7.0 (R2010a) MATLAB Compiler Version 4.13 (R2010a) Neural Network Toolbox Version 6.0.4 (R2010a) Optimization ...

??? Undefined function or method 'secproj' for input arguments of type 'function_handle'.
Hello all. I have a function, 'secproj' which in turns calls another function 'proj'. Function 'proj' takes as it's first argument a function handler. In order to pass this function handler to function 'proj' I pass that same function handler to the function 'secproj'. While calling 'proj' directly works just fine, when I call 'secproj', I get the error message "??? Undefined function or method 'secproj' for input arguments of type 'function_handle'." and I am having trouble figuring out why. Any...

Web resources about - fminsearch error: "Undefined function or method 'L' for input arguments of type 'double'" - comp.soft-sys.matlab

Resources last updated: 3/14/2016 3:27:37 AM