[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: independent variable in function for leasqr
From: |
oxyopes |
Subject: |
Re: independent variable in function for leasqr |
Date: |
Mon, 9 Jul 2007 16:51:39 +0200 |
Hi James,
thanks for the help. Unfortunately this code does not work for me (details at
the end). I cannot make a function work if not all letter constants are
specified as variables. Example: this works
F=inline("Ao*exp(-D*x.^2*k)","Ao","D","x","k"); F(1,2,3,4)
But only if Ao, D, x and k are specified as variables, even if i want
Ao, D, and k to be constants. So this wont work
F=inline("Ao*exp(-D*x.^2*k)","Ao","D","x"); k=1; F(1,2,3)
As a results, i do not know how to tell leasqr which is the
independent variable and which constants are to
be optimized when i type leasqr(g,A, guess, F ).
How to give this information to leasqr?
Following your last email I had the following result:
octave-2.1.73:116> g=(1:2:10)'; A=exp(g); Ao=1; k=2; guess=[1 0.1]';
octave-2.1.73:118> F = inline("Ao*exp(-D*x^2*k)","Ao","D","x")
octave-2.1.73:121> leasqr(g,A, guess, F )
error: `x' undefined near line 117 column 23
error: evaluating binary operator `^' near line 117, column 24
Is it maybe the octave version?
Thanks again for any help ...
Lets let p(1) = Ao and p(2) = D.
Now our function is defined this way:
k=2;
F = inline(" p(1)*exp(-p(2)*x.^2*k) ", "x", "p");
The "x" and the "p" denote that they are the only input variables. Notice
also the .^ there because when leasqr calls F it will put in the whole
vector x (in this case your variable g) and expects the output of F to be a
vector the same size as y (or in your case A). So, my code looks like:
g=(1:2:10)';
A=exp(g);
k=1;
F = inline(" p(1)*exp(-p(2)*x.^2*k) ", "x", "p");
guess=[1 0.1]';
[f1, p1, kvg1, iter1, corp1, covp1, covr1, stdresid1, Z1, r21] = leasqr(g,A,
guess, F );
- independent variable in function for leasqr, oxyopes, 2007/07/08
- Re: independent variable in function for leasqr, James Sherman Jr., 2007/07/08
- Re: independent variable in function for leasqr,
oxyopes <=
- Re: independent variable in function for leasqr, James Sherman Jr., 2007/07/09
- Re: independent variable in function for leasqr, oxyopes, 2007/07/10
- Re: independent variable in function for leasqr, David Bateman, 2007/07/10
- Re: independent variable in function for leasqr, Guillem Borrell Nogueras, 2007/07/10
- Re: independent variable in function for leasqr, David Bateman, 2007/07/10
- Useless functions in matlab function library., Guillem Borrell Nogueras, 2007/07/10
- Re: Useless functions in matlab function library., Qingshan Chen, 2007/07/10
- Re: Useless functions in matlab function library., Jordi GutiƩrrez Hermoso, 2007/07/10
- Re: Useless functions in matlab function library., Guillem Borrell Nogueras, 2007/07/11
- Re: Useless functions in matlab function library., Paul Kienzle, 2007/07/11