class property referred in a legend

3 次查看(过去 30 天)
Aga
Aga 2014-2-13
评论: Aga 2014-2-18
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 个评论
Rizwana
Rizwana 2014-2-14
legend 'dataset.time dataset.voltage'
Aga
Aga 2014-2-18
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..

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by