[Scilab-users] Getting the variable name used for a function input argument
Samuel Gougeon
sgougeon at free.fr
Sun Dec 5 20:02:03 CET 2021
Le 04/12/2021 à 20:59, Samuel Gougeon a écrit :
>
> So, /unless you need to know the name *inside* printc() for some
> unsaid purpose/, what would be the difference between in one hand
>
> [name, mag, arg] = printc(myvar, "myvar")
>
> and on the other hand
>
> name = "myvar";
> [mag, arg] = printc(myvar)
>
> ?
>
So, after your mail in private, you actually needs the variable's name
inside the function.
Then, the easiest way to do what you expect could be to pass only the name:
function printc(name)
execstr("c = "+name)
//Drucken einer komplexen Zahl mit Betrag und Winkel/°
mprintf([name+': %f /_%7.2f°\n'],abs(c), 180/%pi*atan(imag(c),real(c)))
endfunction
--> myVar = 3 - 2*%i
myVar =
3. - 2.i
--> printc myVar
myVar: 3.605551 /_ -33.69°
Regards
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20211205/e7ff827e/attachment.htm>
More information about the users
mailing list