From: Zukri on 12 Jul 2010 12:52 Walter Roberson <roberson(a)hushmail.com> wrote in message <reG_n.6884$KT3.2303(a)newsfe13.iad>... > Zukri wrote: > > Thanks a lot, Walter. :) However, I've still got a problem. Here's what > > I've got from MatLab: > > > > U = > > 10 12 14 16 > > > > Name Size Bytes Class Attributes > > U 1x4 32 double > > So I've applied as mentioned; > >> tUs = str2num(U.'); > >> legend(tUs{:}); > > and the error - Requires string or character array input. > > tUs = cellstr(str2num(U.')); > legend(tUs{:}); > > should do it. > > > Also, what does U{:} mean? > > F(V{:}) is the same as if you had written > > F(V{1}, V{2}, V{3}, ... V{end}) > > provided that V is a cell array. See the Getting Started section of the > documentation for more information about cell arrays. Thanks for helping, guys. Unfortunately there's still an error. Here's what I've written: X = [1 2 3 4] Y = [1 2 3 4] %line1 Y1 = [5 6 7 8] %line2 Y2 = [9 10 11 12] %line3 U = [1 2 3] % trying to get values of U to to represent as the Legend plot(X,Y,X,Y1,X,Y2) tUs = cellstr(str2num(U.')); legend(tUs{:}); The error is : ??? Error using ==> str2num at 33 Requires string or character array input. Error in ==> sample at 10 tUs = cellstr(str2num(U.')); I've also tried the num2cell suggested by Paul, but that didn't work either. |