Transpose an arbitrarily sized rectangular Matrix.




mtrx$ ="4, 3,   0, 0.10, 0.20, 0.30,   0.40, 0.50, 0.60, 0.70,  0.80, 0.90, 1.00, 1.10"
 
print "Transpose of matrix"
call DisplayMatrix mtrx$
print "         ="
MatrixT$ =MatrixTranspose$(mtrx$)
call DisplayMatrix MatrixT$
 
end
 
function MatrixTranspose$(in$)
  w	= val(word$(in$, 1, ","))    '   swap w and h parameters
  h	= val(word$(in$, 2, ","))
  t$	= str$(h); ","; str$(w); ","
  for i =1 to w
    for j =1 to h
      t$ = t$ +word$(in$, 2 +i +(j -1) *w, ",") +","
    next j
  next i
MatrixTranspose$ =left$(t$, len(t$) -1)
end function
 
sub DisplayMatrix in$   '   Display looking like a matrix!
html "<table border=2>"
  w	= val(word$(in$, 1, ","))
  h	= val(word$(in$, 2, ","))
  for i =0 to h -1
   html "<tr align=right>"
   for j =1 to w
      term$	= word$(in$, j +2 +i *w, ",")
      html "<td>";val(term$);"</td>"
    next j
html "</tr>"
next i
html "</table>"
end sub