10 Reputation

6 years, 101 days

How to make the rows of a matrix into a ...

Maple 17

I am trying to find a way to take the rows of a matrix and put them in a sequence.  For example if i have the matrix

M:=Matrix(3,[[1,1,1],[2,2,2],[3,3,3]]);

I want to rewrite it as S:= {111222333}.

Sorry if this is not clear.  I know how to create a sequence, but I want to be able to use the Matrix and output a sequence without manually inputing the numbers.

Spiral Matrix Procedure in Maple...

Maple

I am wanting to write a procedure to take a square matrix and have it output a spiral matrix.

for example; M:=Matrix(3,[[1,1,1],[2,2,2],[3,3,3]]);

would turn into

S:=Matrix(3,[[1,1,1],[3,3,2],[3,2,2]]);

Starting in the top left corner and each row follows around clockwise until you reach the middle.

My first thought was I need to be able to call each element (m_i,j) from a matrix and tell it where to go. I could write a different procedure for each square matrix assigning where the elements in the matrix each should move to. Since I could not get it to work for n.

Here is what i have for a 3x3 matrix

Spiral := proc(a1,a2,a3,b1,b2,b3,c1,c2,c3)
local M,S;
M:=Matrix(3,[[a1,a2,a3],[b1,b2,b3],[c1,c2,c3]]);
S:=Matrix(3,[[a1,a2,a3],[c2,c3,b1],[c1,b3,b2]]);
print(M);
print(S);
end:
Spiral(1,2,3,4,5,6,7,8,9);

It is very difficult for me to find information about Matrices in Maple. Any hint on using Maple would be appreciated. Thank you.

 Page 1 of 1
﻿