Matrix Size

2.22K viewsModel Design
0

Is there a way to find the size of matrices within a model?

Answered question
0

Hi Shrishank,
There is no inbuilt functionality to get this information on a per-matrix basis. As Rich indicated you can easily get this information for the model as a whole.
Whilst I am not a scripting expert, I wrote this simple script which should allow you to find out basic information about a selected matrix:

def allMatrices = matrices*.name // Scan the model and put all the matrix names in a list
def String chooseMatrixMessage = “Choose a Matrix:”
def chosenMatrix = ask(chooseMatrixMessage,[“Matrix”:allMatrices]) // Let the user select a matrix name from the list
selectedMatrix = matrices[chosenMatrix[“Matrix”]] // Select the matrix using the name that the user selected
def numCategories = selectedMatrix.categories*.name.size().toString()
def numCells = selectedMatrix.values.size().toString()
def numFormulas = selectedMatrix.formulae.size.toString()
alert(“Details for “+ selectedMatrix.name.toString() + “nn” + “Categories: “+ numCategories + “n” + “Cells: ” + numCells + “n” + “Formulas: ” + numFormulas)

Kind Regards,
James

Answered question
You are viewing 1 out of 2 answers, click here to view all answers.