Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
I need to generate a function which has three values (Beta , alfa and distance )
when Beta values will be the mean operator for example when beta=0 the function will run in all alfa and distance values to find the solution
Then it goes to the second beta value=15 and do the same .....until it does for all 24 values of beta
in my excel sheet I have 24 tables , I attached the excel and mathcad sheets
I tried to do it as follows but it didn't work ?
Solved! Go to Solution.
1) "alpha" and "Distance" are both (2-dimensional) 9 x 9 matrices.
1a) Accessing elements of such a matrix require the use of TWO indices (row and column). You are using just one index, so Prime can't possibly know which element you mean or if you mean a whole column or row.
1b) "length( )" can only be used to get the number of elements in a (1-dimensional) n x 1 matrix = column vector. For 2-dimensional matrices you can use the functions "rows( )" and "cols( )" to get the number of rows and columns.
2) Prime does not support 3-dimensional structures so you can't use three indices like in
If you really need a structure like a 9 x 24 x 9 "matrix", you could create nested matrices. Perhaps a 9 x 1 matrix (= column vector) which consists of 9 matrices with dimension 24 x 9. Or a 9 x 24 matrix where each element is a 9 x 1 vector. Depends on your needs.
3) Loops in programs are created using ranges! If you write then j takes only ONE value (in this case 24). If you want to run j from the first index (1 in your sheet) to the last (24 in case of Beta) you would have to write. Using "last" instead of "length" assures that the program also works OK if the system variable ORIGIN is set to something different than 1.
Not sure what exactly you are trying to create, but maybe this function can be of help:
It creates a 9x9 matrix for every of the 24 values in Beta and collect them in a 24 x 1 vector:
Showing just the first two ...
Of course you can access individual elements the usual way, here the matrix you get for Beta with index 10:
1) "alpha" and "Distance" are both (2-dimensional) 9 x 9 matrices.
1a) Accessing elements of such a matrix require the use of TWO indices (row and column). You are using just one index, so Prime can't possibly know which element you mean or if you mean a whole column or row.
1b) "length( )" can only be used to get the number of elements in a (1-dimensional) n x 1 matrix = column vector. For 2-dimensional matrices you can use the functions "rows( )" and "cols( )" to get the number of rows and columns.
2) Prime does not support 3-dimensional structures so you can't use three indices like in
If you really need a structure like a 9 x 24 x 9 "matrix", you could create nested matrices. Perhaps a 9 x 1 matrix (= column vector) which consists of 9 matrices with dimension 24 x 9. Or a 9 x 24 matrix where each element is a 9 x 1 vector. Depends on your needs.
3) Loops in programs are created using ranges! If you write then j takes only ONE value (in this case 24). If you want to run j from the first index (1 in your sheet) to the last (24 in case of Beta) you would have to write. Using "last" instead of "length" assures that the program also works OK if the system variable ORIGIN is set to something different than 1.
Not sure what exactly you are trying to create, but maybe this function can be of help:
It creates a 9x9 matrix for every of the 24 values in Beta and collect them in a 24 x 1 vector:
Showing just the first two ...
Of course you can access individual elements the usual way, here the matrix you get for Beta with index 10:
Hi Werner,
I hope you are doing well.
I need to take this sheet a step further. Now after we get 24 matrics . I need to find the minimum value in each column in each matrix.
For example: matrix Linters 23 will have a matrix of the minimum values of each colunm . I tried to do it as follows but couldn't get what i want since it gives me the minimum in the whole matrix . I need the minimum in each column in each matrix.
Like in excel you select the colunum and find the minimum in that column. Sorry for bothering you a lot. But I genuinely appreciate your help