Community Tip - You can change your system assigned username to something more personal in your community settings. 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
Dear Werner
Do you still remember this issue , I was reviewing again and I discovered that the operator (i) is not working it works only for l-interest 1. Then it repeats itself . Why do you think so?
No, I don't remember.
What are the results which are wrong in your opinion and which results do you expect?
I notice that the values in your vector Beta are 0, 15, 30, etc. These ARE NOT angles in degree. If you use them later as angles, they are assumed to be radian!!
And because Beta contains these large values, the condition
would be true for all i>0.
Prime can deal with units and so you should use "deg" if you mean degree.
Maybe this little change solves your problem:
The same result can be achieved with
which may be a little bit more efficient because we omitted the unnecxessary assigment O <... 0 and B1 is assigned just once and not for every loop value j.
Then we get
Werner , I hope one day I meet and give you a gift . Your answers always so detailed and understandable . That's really impressive. Thank you so much.