HTBasic Help
×
Menu
Index

trn Example

10    DIM Matrix(1:3,1:3),M(1:3,1:3)
20    DATA 1, 2, 3, 4, 5, 6, 7, 8, 9
30    RESTORE
40    READ Matrix(*)
50    CLEAR SCREEN
60    PRINT "The matrix looks like: "
70    Prtmat(Matrix(*),3,3)
80    MAT M=TRN(Matrix)
90    PRINT "Transpose matrix"
100  Prtmat(M(*),3,3)
110  END
120  SUB Prtmat(A(*),Lenarr,Widarr)
130    ! This sub prints out a matrix length of Lenarr and wide as Widarr.
140    ! A 3x3 matrix would print like:
150    !           [ 1 2 3 ]  Widarr = 3
160    !           [ 4 5 6 ]
170    !           [ 7 8 9 ]
180    !           Lenarr = 3
190    ASSIGN @Out TO CRT
200    FOR Col=1 TO Lenarr
210      OUTPUT @Out;"  [";
220      FOR Row=1 TO Widarr
230        OUTPUT @Out;A(Col,Row);
240      NEXT Row
250      OUTPUT @Out;" ]"
260    NEXT Col
270    ASSIGN @Out TO *
280  SUBEND