help-octave
[Top][All Lists]

Re: solving non-linear set of equations

 From: Fritz Fischer Subject: Re: solving non-linear set of equations Date: Thu, 29 Sep 2011 07:58:43 +0200

Perfect!  This is working!

I did some further research on this topic, and if one needs
"anonymous function"

See here
http://www.network-theory.co.uk/docs/octave3/octave_113.html

or here

http://www.mathworks.de/help/toolbox/optim/ug/brhkghv-7.html?
http://www.mathworks.de/help/techdoc/matlab_prog/f4-70115.html

Kind regards,
Walter

2011/9/28 c.

On 28 Sep 2011, at 12:50, Fritz Fischer wrote:

>
> I read somewhere that I have to create a single file with myfunc. Is this
> correct? Or is there a way to use this from within the function heat_flux ?

yes, you can write the definition of "myfunc" within the file heat_flux.m like this:

....
[x, info] = fsolve (@myfun, [10; 10; 10; 10; 10;10])

endfunction

function y = myfun (x)
....
endfunction

> If there is a way to use it from within, is it allowed to call the variables
> like T_sky_kelvin or T_ambient_kelvin ?

If these variables are defined within the body of
the function "heat_flux" the will not be visible within
the scope of the function "myfun"

> If not, how do I pass the functions to myfun if i call is using
> [x, info] = fsolve ("myfun", [10; 10; 10; 10; 10;10])

You could do it this way:

T_ambient_kelvin = 334
T_sky_kelvin = 273

[x, info] = fsolve (@(x) myfun (x, T_ambient_kelvin, T_sky_kelvin), [10; 10; 10; 10; 10;10])

endfunction

function y = myfun (x, T_ambient_kelvin, T_sky_kelvin)
....
endfunction

> Or am I doing something completly wrong??
>
> Kind regards,
> Walter

HTH,
c.