Hi,
Thanks for all the responses and sorry for not beeing able to answer
before now.
The background of my question was to write a function for formatted
output of complex variables in polar form with
mprintf like
function printc(c)
which returns the name of c on calling level, |c|, and the angle.
I understand now that I have to write e. g.
function printc(c,cname)
where cname is the wanted string. This can even give some additional
freedeom in modifying the output name.
Regards
Jens
Am 24.11.2021 um 09:51 schrieb Stéphane Mottelet:
Hi,
Le 24/11/2021 à 01:42, Federico Miyara a écrit :
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.
No. Internally, input arguments are passed as references to the true
object. There is no copy unless an input argument is modified in the
function (in that case a copy with local scope only).
The name is lost in the process.
Yes, before the first line of the function body the original object
has the name of the argument, although both names refer to the same
object.
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.
I think that we are in the presence of an XY problem
(https://xyproblem.info/) and that Jens should explain the whole story.
S.
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
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
Libre de virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
_______________________________________________
users mailing list
[email protected]
http://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
[email protected]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users