Skip to main content
1-Visitor
April 24, 2013
Solved

How to limit the size of a matrix in Mathcad

  • April 24, 2013
  • 2 replies
  • 1600 views

Hello,

I am trying to limit the size of a 10x10 matrix depending on a given variable, for example (n). The 10x10 matrix is the basic matrix with all numbers in it.

(n) is going to be any number from 0 to 10. for instance, if I put n=6, the matrix is going to be 6x6 with its numbers coming from the 10x10 matrix.

To be more clear, if I have this matrix which is 10x10 ( the basic matrix) with all its variables are given:

K=[ k1+k2 -k2 0 0 0 0 0 0 0 0 ;

-k2 k2+k3 -k3 0 0 0 0 0 0 0 ;

0 -k3 k3+k4 -k4 0 0 0 0 0 0 ;

0 0 -k4 k4+k5 -k5 0 0 0 0 0 ;

0 0 0 -k5 k5+k6 -k6 0 0 0 0 ;

0 0 0 0 -k6 k6+k7 -k7 0 0 0 ;

0 0 0 0 0 -k7 k7+k8 -k8 0 0 ;

0 0 0 0 0 0 -k8 k8+k9 -k9 0 ;

0 0 0 0 0 0 0 -k9 k9+k10 -k10 ;

0 0 0 0 0 0 0 0 -k10 k10]

If I put n=3, the matrix will be 3x3 coming from the 10x10 matrix (the basic matrix):

K=[ k1+k2 -k2 0 ;

-k2 k2+k3 -k3

0 -k3 k3+k4]

Thank you in advance.

Best answer by MoeSzyslak

extract(M,n):=submatrix(M,0,n-1,0,n-1)

2 replies

12-Amethyst
April 24, 2013

extract(M,n):=submatrix(M,0,n-1,0,n-1)

A_B1-VisitorAuthor
1-Visitor
April 24, 2013

That works.

Thanks alot.