I'm not completely sure, but I think this is not possible since what is passed to the function isn't a variable but the value contained in the variable. The name is lost in the process.

An alternative way (but I don't know if this would be acceptable for you) is that the function had as its argument a variable name (hence, a string), so your x would be "xNum", instead of 123. Then you could use evstr() to get the value of the variable to proceed with the processing.

Regards,

Federico Miyara


On 23/11/2021 17:18, Jens Simon Strom wrote:

Hi Scilab friends,
Given a numeric variable like xNum as an input argument of a function call, how can I produce the variable name string "xNum" within the function?

Example:

function [name,y]=foo(x)
   name=???
   y=x^2
endfunction

xNum=123.
[name,y]=foo(xNum)
The result for name should be the string "xNum"

Regards
Jens
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users





--
El software de antivirus Avast ha analizado este correo electrónico en busca de 
virus.
https://www.avast.com/antivirus
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to