Filter löschen
Filter löschen

plot help

13 Ansichten (letzte 30 Tage)
Edward am 11 Mai 2012
Hi, im trying to write a simple program to put a legend on the graph using variable names as strings for example i have
how do i get these onto a legend?
I don't want to use legend(var1,var2) as i intend to plot n variables with n different names.

Antworten (1)

Walter Roberson
Walter Roberson am 11 Mai 2012
vars = {'name1', 'name2'};
  3 Kommentare
Walter Roberson
Walter Roberson am 11 Mai 2012
In a duplicate of this question, the claim was made that this does not allow different numbers of strings for each execution. That is not correct.
For example,
nv = ceil(10 * rand);
vars = cell(1,nv);
for K = 1 : nv
vars{K} = char('a' + floor(20*rand(1,5)));
Dr. Seis
Dr. Seis am 11 Mai 2012
If "vars" is a cell string... why do you need the {:}, why not just legend(vars) ?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by