[Scilab-users] Passing argument to function by reference

Mathieu Dubois mathieu.dubois at limsi.fr
Tue Nov 20 01:35:21 CET 2012


Hello,

I don't think that scilab has call by reference.

Maybe I misunderstood your problem but the function could return the 
updated matrix and you replace the old value with the new one it in the 
loop. If you know which columns you will update you can use block 
assignment to avoid passing large matrices.

HTH,
Mathieu

Le 16/11/2012 10:37, Laurent Cetinsoy a écrit :
> Dear all,
>
> For a simulation, I need to update a matrix in a loop. The thing is, 
> I
> only need to update a few rows. And since this code is to be used in
> different part, I would like to include it in a function. Beside I 
> would
> like to avoid using “global” variable.
>
> Here is it what I want to do :
>
> myMat = zeros(nrow, ncol)
>
> For I =1 :i_max
>
> fUpdateMat( reference myMat)
>
>                  etc…
>
> end
>
> function fUpdateMat(Mat)
>
>                  Mat(2:3) = …
>
>                  Mat(4) = …
>
>                  Mat(10) = …
>
>                  Etc…
>
> end function
>
> I do not want to include this into a scrip (.sce) file and execute it
> with “exec” because reading a written file in a loop slows down the
> computation greatly.
>
> I would be pleased if you have any suggestion.
>
> Regards,
>
> Laurent
>
> __________________________________
>
> *Laurent Cetinsoy***
>
> /Research Analyst/
>
> /Health Economics and Outcomes Research/
>
> LOGO Q + CLAIM HD petite
>
> 215, rue du Faubourg St-Honoré
>
> 75008 Paris - France
>
> Phone:  +33 1 76 70 47 90
>
> Fax:        +33 1 53 75 49 24
>
> www.creativ-ceutical.com <http://www.creativ-ceutical.com/>__
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>




More information about the users mailing list