## put vector into matlab figure legend

February 1st, 2008 by Lawrence David

let’s say you’ve got a bunch of lines in a matlab plot whose labels live in a vector. to place all of those labels into the same figure legend, you can do the following:

>> vec

vec =

1

2

3

4

5>> legend([repmat('penalty = ',length(vec),1) num2str(vec)])

the result: