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