On 05/25/2014 03:05 PM, message wrote:
Readers,
The function 'fsolve' was attempted to be used to solve the
following simultaneous equations:
equation 1: 4.2=2x+4y; equation 2: 6.3=4x+y
Octave is about linear algebra, and these equations can be written
in a matrix form (C=A*x) as follows:
[4.2 6.3] = [2 4; 4 1] * x. Now, in Octave you can solve this
equation simply as x=C/A. I leave the details out so you can play
with them a little to better understand the logical and syntactic
requirements of Octave notation.
function y=f(x)
ya=-4.2+2*x+4*4.2/4-2*x/4;
yb=-6.3+4*x+4.2/4-2*x/4;
endfunction
[x,info]=fsolve(@f,[1;2])
Using fsolve for this system is possible but not the natural thing
to do.
|