I want the name of my variables in a plot legend in matlab. Is this possible?
my example is:
function example(x1)
figure;
plot(x1.time, x1.value);
legend(x1);
end
now I want to call my function like:
>> example(myvariable)
my legend should look like:
---------------
| -- myvariable |
---------------
thanks for your help guys.
You can use
inputnameto get the name of the input in the calling workspace and then pass this tolegendor set theDisplayNameproperty of the plot to this value.