Le 23/05/2019 à 09:34, Dang Ngoc Chan, Christophe a écrit :
Hello,

De : Carrico, Paul
Envoyé : jeudi 23 mai 2019 09:21

I share your suggestion in adding an example in the doc to prevent Scilab
users, but the question is "where" ?
I suggest the "Scilab Help >> Elementary Functions > extraction" page.

I am not sure that is the right place. In fact our discussion is about the general concepts of *lvalue* and *rvalue* (in most languages, compiled or interpreted, see e.g. https://www.quora.com/What-is-lvalue-and-rvalue-in-C which starts with general stuff valuable for Scilab also)

In this insertion expression:

x(i) = y

x(i) determines the identity of an object, and we need this because the evaluation of the expression will modify it . In this case "x(i)" is a *lvalue*. The "l" is to recall that such constructs are to the *left* of the assignment operator

In this extraction expression:

y = x(i)

"x(i)" is a *rvalue*, i.e. a "result"  which is _temporary_ materialized, and identity of x is lost (because we don't need it). Here the "r" can be seen as "right" as well as "result" (I prefer "result"...)

Hence, in the expressions

x=rand(10,1);
[v,k]=find(x(3:10))

find() just sees an anonymous/temporary 8x1 vector. It is the user's responsibility to do

k=k+2

to compute the actual index in original vector.

S.


Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error), please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden.
_______________________________________________
users mailing list
users@lists.scilab.org
https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users


--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to