From: sdv on 9 Mar 2010 06:39 I would like to append lines in the legend for every plot cycle in the following loop. The plotting takes place inside a function, which gets A=[] as an argument. Here, I am emulating this with a simple for loop. The length(A) is an arbitrary number, most likely to vary. Can anyone help? Thanks in advance, sdv for k = 1:1:length(A) figure(1) plot(X(k), Y(k)); legend(num2str(A(k)), 'Location', 'Best'); hold all; end
From: S. Kauth on 9 Mar 2010 08:02 Am 09.03.2010 12:39, schrieb sdv: > I would like to append lines in the legend for every plot cycle in the > following loop. The plotting takes place inside a function, which gets > A=[] as an argument. Here, I am emulating this with a simple for loop. > The length(A) is an arbitrary number, most likely to vary. Can anyone > help? Thanks in advance, sdv > > for k = 1:1:length(A) > figure(1) > plot(X(k), Y(k)); > legend(num2str(A(k)), 'Location', 'Best'); > hold all; > end I once accomplished this by something like this: figure(1); legendtext =''; for k = 1:1:length(A) plot(X(k), Y(k)); legendtext = [legendtext; num2str(A(k)), 'Location', 'Best'] hold all; end legend(legendtext);
From: Husam Aldahiyat on 9 Mar 2010 08:23 "sdv " <sofia.vatti(a)m4s.be> wrote in message <hn5c0n$i2s$1(a)fred.mathworks.com>... > I would like to append lines in the legend for every plot cycle in the following loop. The plotting takes place inside a function, which gets A=[] as an argument. Here, I am emulating this with a simple for loop. The length(A) is an arbitrary number, most likely to vary. Can anyone help? Thanks in advance, sdv > > for k = 1:1:length(A) > figure(1) > plot(X(k), Y(k)); > legend(num2str(A(k)), 'Location', 'Best'); > hold all; > end Use findobj() and the handle syntax of using legend(), both outside the loop.
|
Pages: 1 Prev: Polyfit?????? Next: Significance test and Confidence bound for Correlation scorein Matlab |