help-octave
[Top][All Lists]
Advanced

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

Re: Using fsolve with time series data


From: Alexander Barth
Subject: Re: Using fsolve with time series data
Date: Fri, 9 Aug 2013 13:50:07 +0200

Dear Terry,

For octave "x(1)" is always a scalar, not a vector. In fact, you have 8 * N scalar unknowns. Thus x can be written as a N x 8 (or 8 x N, but this will be slower in your case) matrix of unknowns. 
You have to write your function fcn like this:

x(:,7) - R1*x(:,3) + R1*x(:,6) - R1*x(:,5).*x(:,5) - R1*x(:,2).*x(:,2) - A1
...

I assume that you mean by x(5)*x(5) a element-wise product. If it is a scalar product use  x(:,5)'*x(:,5).
Call then fsolve with

[x, fvec, info] = fsolve(fcn, zeros(N,8));

I hope this helps.

Cheers,
Alex



On Fri, Aug 9, 2013 at 4:43 AM, Terry Duell <address@hidden> wrote:
Hello All,
I am trying to solve a system of equations that involve time series data.
My system of equations are of the general form...

A1 = A0 - R1*x(3) + R1*x(6) - R1*x(5)*x(5) -R1*x(2)*x(2)
A2 = A0 - R2*x(3) + R2*x(6) - R2*x(5)*x(5) -R2*x(2)*x(2)

etc

where A1, A2...are known vectors (1,N).
R1, R2 etc are known scalars.
A0 is an unknown vector (1,N)
The other unknown variables, x(1), x(2) etc should be vectors (1,N).
I have 8 unknowns and 8 equations.
I have set up a script, where I define the scalars (R1 etc), and my known vectors, and define my
function in this form...

fcn = @(x) [x(7) - R1*x(3) + R1*x(6) - R1*x(5)*x(5) - R1*x(2)*x(2) - A1,
...
                for all the equations
              ];

% where x(7) = A0,
and call fsolve, thus...

[x, fvec, info] = fsolve(fcn, [0 0 0 0 0 0 0 0]);

This is returning a solution, but the x(i) values that are returned are
scalars. They should be vectors (1,N).

Is it possible to solve a problem of this type, and if so, how should I reformulate/correct my approach so that the solution returns the x's as vectors?

Cheers,
--
Regards,
Terry Duell
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


reply via email to

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