From: us on 27 Jul 2010 18:13 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i2nkpd$r4b$1(a)fred.mathworks.com>... > Dear Matt Fig, > > > for xx= {'TSO' 'VLO'} ,xx,end > > Is this a documented feature? It worked in Matlab 6.5 already, but I cannot find a hint in the help or doc. > > Deeply impressed to learn something new about such a basic function, Jan huh(!?)... you MUST be kidding, jan... :-) urs
From: Matt Fig on 27 Jul 2010 18:14 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i2nkpd$r4b$1(a)fred.mathworks.com>... > Dear Matt Fig, > > > for xx= {'TSO' 'VLO'} ,xx,end > > Is this a documented feature? It worked in Matlab 6.5 already, but I cannot find a hint in the help or doc. > > Deeply impressed to learn something new about such a basic function, Jan Yes, in the doc for the FOR function: "The line for V = A, ..., end has the same effect as for k = 1:n, V = A(:,k); ..., end except k is also set here."
From: Jan Simon on 27 Jul 2010 18:36 Dear Urs, > > > for xx= {'TSO' 'VLO'} ,xx,end > > Deeply impressed to learn something new about such a basic function, Jan > you MUST be kidding, jan... No, not kidding, Urs. FOR is *really* basic. In fact, the help of FOR claims: "FOR variable = expr, ... The columns of the expression are stored one at a time ...". I've done this with row vectors and matrices, but never with cell or struct arrays. Wow. I think I should look into the "Getting started" again to find the other gems. Perhaps I'll find even a function, which can evaluate a string as if it would be typed in the command line? It would be so powerful. Or some lessons about English grammar? Good night, Jan
From: Steven_Lord on 28 Jul 2010 11:19 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message news:i2nn0k$kni$1(a)fred.mathworks.com... > Dear Urs, > >> > > for xx= {'TSO' 'VLO'} ,xx,end > >> > Deeply impressed to learn something new about such a basic function, >> > Jan >> you MUST be kidding, jan... > > No, not kidding, Urs. FOR is *really* basic. But even basic functions can have surprising (hopefully in a good way) behavior, even for experienced users. > In fact, the help of FOR claims: > "FOR variable = expr, ... The columns of the expression are stored one at > a time ...". I've done this with row vectors and matrices, but never with > cell or struct arrays. Yes, that's why that code worked. The FOR loop is iterating through the columns of the 1-by-2 cell array; first xx takes on the value of the first column of the cell array, aka {'TSO'} then it takes on the second column {'VLO'}. Neat, huh? > Wow. I think I should look into the "Getting started" again to find the > other gems. Perhaps I'll find even a function, which can evaluate a string > as if it would be typed in the command line? It would be so powerful. To quote Uncle Ben: "With great power comes great responsibility" ... in this case the responsibility to keep people from using EVAL when unnecessary or dangerous :) > Or some lessons about English grammar? > > Good night, Jan -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
First
|
Prev
|
Pages: 1 2 3 Prev: Serial terminator question Next: Design of Experiments using statistics toolbox |