From: Stavros M. (Σ. Μ. <mac...@al...> - 2019-03-05 18:17:59
|
In Maxima, a matrix is represented as matrix( row1, row2, ...) where each row is a list. In 2-dimensional teletype notation, a matrix looks like: [ a b ] [ ] [ c d ] In 1-dimensional teletype notation, it looks like: matrix([a,b],[c,d]) And in Tex output (e.g., from wxMaxima), it looks like: [image: image.png] Maxima normally represents row and column matrices as matrices where one of the dimensions happens to be 1. Maxima also allows matrix operations between matrices and lists, which are interpreted as 1xn or nx1 matrices, but let's not get into that. m[i,j] returns the element in row i, column j. row(m,i) returns row i *as a matrix.* col(m,i) returns column i *as a matrix.* Thus, in your example, I think what you want is m1[i,1]. Matrices can also be considered to be a list of lists: m[i] or part(m,i) returns row i *as a list*, not a matrix. If you want to convert a column vector into a list, probably the easiest way is tranpose(m)[1]. On Tue, Mar 5, 2019 at 10:51 AM Ronald Modesitt < ron...@gm...> wrote: > I write a line of code such as > m1: col(M,1), > where M is a matrix of integer values (951 x 6) and '1' is the column of M > that I wish to extract. I am expecting that m1 will be a column matrix. > However it appears to me that what is returned is a column matrix of > matrices. > > m1 = [ > [] > [] > . > . > . > [] > [] > [] > ] > > my actual code is: > c1: zeromatrix(75,1)$ > m1:col(M,1)$ > lm: length(M)$ > for i: 1 step 1 thru lm do > (x: m1[i], > print("x= ",x), > c1[x]: c1[x]+1)$ > > the resulting error message is: > > x= [65] > apply: subscript must be an integer; found: [65] > -- an error. To debug this try: debugmode(true); > > Am I misinterpreting the syntax of col(M,i) or misusing it altogether? > > Thanks > > Ron > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |