I want to dynamically assign a legend to a data set with a changing number of vectors (v_1, v_2,…,v_n) that I plot against a single vector A. The vectors v_n are stored in a cell array, T{1,n}.
Some psuedo-code would be something like,
n=5for i=1:n plot(A,T{1,i}) legend('X=',i) % Essentially I want something like, legend('X=1', 'X=2', 'X=3', 'X=4', 'X=5',..., 'X=n')
end
So in this example by setting the value of n to be 5, I should get 5 different plots on my graph with a legend that displays X=1 through to X=5.
Is there a way to do this?
Thank you!
Best Answer