class property referred in a legend

3 vues (au cours des 30 derniers jours)
Aga
Aga le 13 Fév 2014
Commenté : Aga le 18 Fév 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 commentaires
Rizwana
Rizwana le 14 Fév 2014
legend 'dataset.time dataset.voltage'
Aga
Aga le 18 Fév 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..

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by