In Matlab, how can i get a String containing "GRUMPY"
given the following declaration:
GRUMPY = 500;
This is usually called reflection in other programming languages, but i cannot find an example of it in Matlab.
MATLAB doesn't provide built-in functionality for this, but there is a workaround, as employed here
Essentially, you have to create your own function to do this. Take advantage of Matlab's functionality for getting the variable name of the INPUT ARGUMENT to a function.
I.e.
function out = varname(var) out = inputname(1); end
Then
GRUMPY = 500; name = varname(GRUMPY)
will give you what you want.
If I understand correctly you should try
who GRUMPY
or
which GRUMPY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With