cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to limit the size of a matrix in Mathcad

A_B
1-Visitor
1-Visitor

How to limit the size of a matrix in Mathcad

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.

ACCEPTED SOLUTION

Accepted Solutions
MoeSzyslak
12-Amethyst
(To:A_B)

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

View solution in original post

2 REPLIES 2
MoeSzyslak
12-Amethyst
(To:A_B)

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

A_B
1-Visitor
1-Visitor
(To:MoeSzyslak)

That works.

Thanks alot.

Announcements

Top Tags