[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help in parameter estimation

From: Nicholas Jankowski
Subject: Re: Help in parameter estimation
Date: Tue, 30 Aug 2016 11:02:51 -0400

On Tue, Aug 30, 2016 at 10:52 AM, Nicholas Jankowski <address@hidden> wrote:
On Tue, Aug 30, 2016 at 10:45 AM, Bharath R <address@hidden> wrote:
Hi Nicholas,

Thanks for the mail. I am sorry that I have used mat earlier, now I changed the function as follows:

function F=f(x,p)
  for i=1:length(x)

I am generating a matrix of [length(x), 1] as output from the function. My measured value is also a matrix of [length(x), 1]. 

What I would like to do now is to estimate parameters p.  I am using the following command to run the optimization program ( I have tried with nonlinear curve fit as well):


pin ,x and y are  initialized. The problem is when I run the optimization algorithm, it throws me the following error:

error: leasqr: subscript indices must be either positive integers less than 2^31 or logicals
error: called from
    leasqr at line 329 column 9

I look forward to your reply. 


On Tue, Aug 30, 2016 at 4:01 PM, Nicholas Jankowski <address@hidden> wrote:
On Tue, Aug 30, 2016 at 6:00 AM, Bharath R <address@hidden> wrote:
function m=f(x,p)
  for i=1:length(x)

is your intent to return the variable m or the variable mat from function f? you are currently returning m and never using mat. since mat is a different size than m, this could make a significant difference when you use the results of f later.

your declaration for m is odd. it asks to make all of the columns in row1 equal to 20.  since m has not yet been initialized, the number of rows is 1. so the output is a 1x1 array, or a scalar, and m = 20. then in the for loop, if the result of the m(i+1,:) equation was 6, you would be appending it as a new row to m, creating a 2x1 array [20 ; 6] . Since you went to the trouble of using the : operator, but have it doing nothing, I suspect this was not your intent?

Can you provide a small sample that I can use for values of x?

without having data to step through, I think the problem is how you are passing your function f to leasqr.  the error message says the error occurs on line 329 in leasqr.  A good thing to try in those cases is " edit leasqr" and if it's an m-file you can look at the code, jump down to the line and see what it's trying to do. 

Line 329 says:

f_pin = F (x, pin); 

So it's trying to use the function F that you passed it, but the error indicates it's treating F as a variable and trying to index into it using 'values' of x and pin, which do not have the proper form for indices.

you should be able to pass your function to leasqr as either a function handle ( pass it as @f )  or a string ( 'f' ) (at there is code up in line 319 to check the input and convert a string input to a function)

See if that makes things work.  if not send a quick set of values for x and I can try stepping through it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]