[Scilab-users] Using lsqrsolve with a certain kind of function
Viktor Goryainov
al_exquemelin at yahoo.com
Tue Jan 3 22:54:09 CET 2017
Happy 2017 and season's greetings!
03.01.2017 15:28, Dang Ngoc Chan, Christophe пишет:
> In the former messages, vr3 needed two arguments
I just moved mu to the beginning of the script. It only changes between
the runs, so I suppose there is no real need to provide it as a
parameter for the function.
03.01.2017 15:28, Dang Ngoc Chan, Christophe пишет:
> Maybe you should provide us a complete and minimal example,
> i.e. a small script that is supposed to work and reproduce the error.
All right, here's what works.
aw15 = linspace(0.038, 0.016, 15)';
achl15 = linspace(0.0162, 0.5, 15)';
asm15 = linspace(0.265, 0.125, 15)';
adoc15 = linspace(0.28, 0.05, 15)';
bw15 = linspace(0.0052, 0.0006, 15)';
bchl15 = linspace(0.00124, 0.00108, 15)';
bsm15 = linspace(0.023, 0.025, 15)';
mu = 0.93;
function r = vr3(C)
a = aw15 + achl15 * C(1) + asm15 * C(2) + adoc15 * C(3);
bb = bw15 + bchl15 * C(1) + bsm15 * C(2);
dd = bb ./ a;
if dd < 0.25 then
r = 0.319 * dd / mu;
else
r = (0.267 * dd + 0.013) / mu;
end
endfunction
C_inh = [0.5 0.6 0.7];
s = vr3(C_inh);
Then, I wrote a function to be used with lsqrsolve(), as the help page
suggests (under the "Data fitting problem" section):
function e = err(C2)
e = s - vr3(C2);
endfunction
Now, if I make an initial guess and try to solve the problem as follows:
C_init = [1 1 1];
[C_s, v] = lsqrsolve(C_init, err, 15);
I then get error 58: "Function has no input argument". So what am I
doing wrong?
Best regards,
Viktor
More information about the users
mailing list