[Top][All Lists]

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

leasqr problem

From: Jose Rodriguez
Subject: leasqr problem
Date: Sat, 24 Jan 2009 12:12:45 +0000


I'm trying to solve a problem with leasqr, where the observed
value, instead of being a set of points y=f(x), is the result of a
definite integral. I found that I can use leasqr if I adjust the
dimensions of the function to fit and its expected values to the
dimension of the x range:


P=@(x)  1/2 * ( 3*cos(x).^2-1 );

F=inline( " ones ( size(x,1), 1 ) * trapz( x, P(x).*
exp(-a*P(x)).*sin(x) ) ", "x", "a" );

y=0.5 * ones ( size(x,1), 1 );

[f,p,kvg,iter,corp,covp,covr,stdresid,Z,r2]=leasqr(x, y, pin, F);

If I run this I obtain the value 'a' for which the integral:

trapz( x, P(x) .* exp(-a*P(x)) .* sin(x) )

is 0.5. 

My problem is that I also want to include a normalisation
condition, like:

1 = trapz( x, exp(-a*P(x)).*sin(x) )

And I thought that I could build F in two columns, the first of
them identical to what I've written above and the second with the
normalisation condition, adjusting again the number of rows to the
x dimension:

F=inline( " [ ones ( size(x,1), 1 ) * trapz( x, P(x).*
( a(1)*exp(-a(2)*P(x)).*sin(x) )   ones ( size(x,1), 1 ) *
trapz( x,  a(1)*exp(-a(2)*P(x)) .*sin(x) ) ] ", "x", "a" );

y=[0.5*ones(size(x,1),1)  ones(size(x,1),1)];
pin=[1 1]';

But this triggers an error from leasqr.m:

"input(x)/output(y) data must have same number of
error: evaluating if command near line 162, column 1

because the script converts all the vectors to columns and thus
size(y(:)) is the double of size(x,1).

Could somebody give me some pointers as to how to proceed? Or am I
completely out of track?



reply via email to

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