Samuel,
Thanks for the response. While the example, I showed is linear, the
equations I want to solve are not. I am thinking I need
a third function which returns a vector. Am I on the right track?
Bob
On 8/28/2016 4:31 PM, Samuel Gougeon wrote:
Le 28/08/2016 22:03, Robert Sherry a écrit :
I defined the following two functions:
function [z]=f(x,y)
z = x + y - 8
endfunction
function [z]=g(x,y)
z = 2*x + y - 8
endfunction
I then wanted to find the roots of the two functions (equations).
That is, I want a pair of numbers (a,b)
such that f(a,b) = g(a,b) = 0. So, I found the function fsolve in the
documentation of Scilab which I believe will do what I want. So, I
ran the following command:
fsolve([0;0],f,g)
and it produced the following error:
Undefined variable: y
at line 2 of function f called by :
fsolve([0;0],f,g)
I do not understand this error and I am hoping that somebody can tell
me what I am doing wrong.
You problem is linear. So there are simpler solutions than fsolve()
that is useful for systems of non-linear equations.
Your system is equivalent to the matrix equation
[1 1 ; 2 1]*X = [ 8 ; 8] with X = [x ; y]
Let set
A = [1 1 ; 2 1] ;
// and
b = [ 8 ; 8];
// from A*X = b, we get X with
X = A\b
--> X = A\b
X =
0.
8.
that means { x=0, y=8 }
Regards
Samuel
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users