class property referred in a legend

3 views (last 30 days)
Aga
Aga on 13 Feb 2014
Commented: Aga on 18 Feb 2014
Dear all, I am new in Matlab. I wanted to plot recalculated data from multiple files. It worked fine with a loop. I also created a class with aproppiate file properties so I could choose what I want to plot. Now I got stacked with a legend. I wanted to paste there reference to a class property, I thought that would automatise my work .Did not work. I would appreciate any hints. Eg. I have defined: dataset.time, dataset.voltage; instead of typing it myself I wanted to have in a loop legend(dataset.time dataset.voltage) what occured to be wrong. thanks in advance!
  2 Comments
Rizwana
Rizwana on 14 Feb 2014
legend 'dataset.time dataset.voltage'
Aga
Aga on 18 Feb 2014
thanks a lot! It might be that I am doing something wrong, but either I typed the way yor wrote it - then the text between '' is treated as string and placed on a legend without reference to true value, or if I omit quotation mark it is just the first one that is taken. What works is :
plot(a,'-r', 'DisplayName', [dataset.voltage,'',dataset.time]);
legend('-DynamicLegend');
that works but after that I am not any more able to refer to column in an easy way as
legend 'dataset.time'.
(Error: "legend" was previously used as a variable,conflicting with its use here as the name of a function
so however it works fine now I am still confused, since I do not understand what has happened Any hints are more than welcome..

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!