help-octave
[Top][All Lists]
Advanced

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

Non linear equations: howto?


From: Fabrice DELENTE
Subject: Non linear equations: howto?
Date: Sun, 19 Oct 2008 15:30:14 +0200
User-agent: Mutt/1.4.2.3i

Hello.

I'd like to solve numerically 6 equations like

f(1)=0
f(2)=2
f(3)=3
f(4)=4
f(5)=2.5
f(6)=-4

where f(x) is defined by

f(x)=(a*x+b)*exp(c*x+d)+e

a, b, c, d and e being the unknowns of my system.

I tried using octave with these commands:

function y = f (x)
  y(1) = (x(1)*1+x(2))*exp(x(3)*1+x(4))+x(5)
  y(2) = (x(1)*2+x(2))*exp(x(3)*2+x(4))+x(5)-1
  y(3) = (x(1)*3+x(2))*exp(x(3)*3+x(4))+x(5)-3
  y(4) = (x(1)*4+x(2))*exp(x(3)*4+x(4))+x(5)-4
  y(5) = (x(1)*5+x(2))*exp(x(3)*5+x(4))+x(5)-2.5
  y(6) = (x(1)*6+x(2))*exp(x(3)*6+x(4))+x(5)+4
endfunction

[x,info]=fsolve("f",[-10;10])

but octave answers

error: invalid vector index = 3
error: evaluating binary operator *' near line 2, column 32
error: evaluating binary operator +' near line 2, column 34
error: evaluating argument list element number 1
error: evaluating binary operator *' near line 2, column 23
error: evaluating binary operator +' near line 2, column 40
error: evaluating assignment expression near line 2, column 8
error: called from f'
error: fsolve: evaluation of user-supplied function failed

How can I give a vector size? Is octave a good tool for solving this kind of
problem? Do you know of any tool that would do the job?

Thanks!

-- 
Fabrice DELENTE


reply via email to

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