[Scilab-users] use of fsolve

Carrico, Paul paul.carrico at esterline.com
Mon Sep 2 15:32:59 CEST 2013


Dear All
A basic question : what is the correct synthax is order to call the
constants cst and R_ in the foo function ? do I need to use "global"
variable ?
Thanks
Paul
function [f, ind]=foo(x, cst, R_, ind)
    f(1) = (x(3) - cst(3))*(x(3) - x(1)) + (x(4) - cst(4))*(x(4) - x(2))
;
    f(2) = (x(1) - cst(1))*(x(3) - x(1)) + (x(2) - cst(2))*(x(4) - x(2))
;
    f(3) = (x(1) - cst(1))^2 + (x(2) - cst(2))^2 - R_(1)^2 ;
    f(4) = (x(3) - cst(3))^2 + (x(4) - cst(4))^2 - R_(2)^2 ;
endfunction

function [f, ind]=foo2(x, ind)
    cst = [106 ; 30 ; 54 ; 15]
    R_ = [9 ; 9]
    f(1) = (x(3) - cst(3))*(x(3) - x(1)) + (x(4) - cst(4))*(x(4) - x(2))
;
    f(2) = (x(1) - cst(1))*(x(3) - x(1)) + (x(2) - cst(2))*(x(4) - x(2))
;
    f(3) = (x(1) - cst(1))^2 + (x(2) - cst(2))^2 - R_(1)^2 ;
    f(4) = (x(3) - cst(3))^2 + (x(4) - cst(4))^2 - R_(2)^2 ;
endfunction

// constants
cst = [106 ; 30 ; 54 ; 15]
R_ = [9 ; 9]

x0 = cst
x1 = zeros(4,1)

// calculationusing fsolve
T1 = fsolve(x0,foo)
T2 = fsolve(x1,foo2)
 

--------------------------------------------------------------------------------


Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130902/644f8bd6/attachment.htm>


More information about the users mailing list