create string with name of variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

create string with name of variable

LucaLuca
This post was updated on .
Example:

global SystemUnique;

functionPrintVariable(SystemUnique);


function functionPrintVariable(var)

     print(name of SystemUnique)  


endfunction

>> "SystemUnique"

how can i do it?

thank




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: create string with name of variable

Pantxo
LucaLuca wrote

> Example:
>
> global SystemUnique;
>
> functionPrintVariable(SystemUnique);
>
>
> function functionPrintVariable(var)
>
>      print(name of SystemUnique)  
>
>
> endfunction
>
>>> "SystemUnique"
>
> how can i do it?
>
> thank
>
>
>
>
> --
> Sent from:
> http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

See "help inputname". The following function should do the trick

function disp_var_name (var)
  disp (inputname (1))
endfunction

a = 2;
disp_var_name (a)

Is it what you want?

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: create string with name of variable

LucaLuca