|
Dear Rick,
I would like to go one step further and do the following: I have 2 column vectors of different lengths, with data, in the same units but from 2 different samples. I want to make a plot and indicate in the legend the units and which sample they come from.
e.g.
v1=[1;2;3;4];
v2=[1;2;3];
How can I make the command legend generate on my plot, a legend like:
1 m, sample 1
2 m, sample 1
3 m, sample 1
4 m, sample 1
1 m, sample 2
2 m, sample 2
3 m, sample 2
I guess I have to use a combination of for loops and strcat, however I think you might know a more efficient way.
Regards,
Miguel.
"Rick Rosson" <rrosson@mathworks.com> wrote in message <faknj3$8aj$1@fred.mathworks.com>...
> Hi Scott,
>
> If 'X' is a column vector, you can use the following:
>
> legend(num2str(X));
>
> Alternatively, if 'X' is a row vector, then try:
>
> legend(num2str(X.'));
>
> I hope that helps.
>
> Thanks.
>
> Rick
>
>
>
> "Scott Sather" <john.doe.nospam@mathworks.com> wrote in message
> news:fakj0r$bem$1@fred.mathworks.com...
> > In my plot I have N curves generated using N values of X. I
> > want my the strings in my legend to show the values of X,
> > i.e., X1, X1, ... XN. Is there an elegant way to do this? I
> > don't want to do the following:
> >
> > legend(num2str(X(1)), num2str(X(2)), ...)
> >
> > because I don't necessarily know what N will be in advance.
> >
> >
>
>
|