The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
Hello everyone,
I am trying to automatize a calculation process in Mathcad, but I am having some difficulties doing it.
Lets say I have a matrix with “n x m” number of rows and columns.
In this example we can have the following matrix (5 x 6 – but it can be different, ex: 10 x 15, 9 x 10 etc...):
Note that Ni is each row of the matrix.
There is a variable “var” that can be equal to 1, 2, 3 or 4.
And finally we have vector “V” (that has always 1 single column, but number of rows depends on the variable “var” however this vector is an input, the values below are just an example):
I want to obtain the following matrix “M” depending on the variable “var”:
- If var = 1 (“V” vector will have just 1 row – F1 = 10)
- If var = 2 (“V” vector will have 2 rows – F1 = 10 / F2 = 1)
- If var = 3 (“V” vector will have 3 rows – F1 = 10 / F2 = 1 / F3 = 4)
- Finally if var = 4 (“V” vector will have 4 rows – F1 = 10 / F2 = 1 / F3= 4 / F = 7)
Any suggestions?
Thank you so much for your help,
Miguel
Solved! Go to Solution.
Good observation, thanks!
Actually the program seems to do the job but for some reason Prime managed to update the creation of the random matrices V and N and using them in the function but did not update the display of N and V. Actually this should never happen (and never did in MC15 and below).
So a hard recalculation of the worksheet fixes this inconsistency which I had not noticed. Thanks for bringing this to my attention.
I attach a new screenshot in my first reply and also attach the worksheet (even though the OP didn't).
Not sure, but is it this what you are looking for?
EDIT: Attached a new screenshot as @terryhendicott had noticed that in the previous one Prime had not displayed the newly created matrices N and V correctly and so the results looked wrong.
Worksheet in P& format attached
Hi
The first row of matrix when v = 1 should be
[18 18 63 ....]
[,,,, ...]
Cheers
Terry
Good observation, thanks!
Actually the program seems to do the job but for some reason Prime managed to update the creation of the random matrices V and N and using them in the function but did not update the display of N and V. Actually this should never happen (and never did in MC15 and below).
So a hard recalculation of the worksheet fixes this inconsistency which I had not noticed. Thanks for bringing this to my attention.
I attach a new screenshot in my first reply and also attach the worksheet (even though the OP didn't).
Hello Werner_E,
Yes it's exactly this I was looking for.
Thank you so much for your help.
(Also Terry thank you for your feedback).
Miguel,
So you want to create a specific matrix, namely a vector, from a matrix, a vector and a variable.
If the matrix is this:
The vector is this:
and the variable is 1 you want:
if the variable is 2 you want:
on to, if it is 4 you want:
That can be easily accomplished by this simple function that also works in Prime express:
A numeric example:
Prime 4 file is attached.
Success!
Luc
Hello Luc,
I was looking for a solution proposed by Werner_E.
Either way thank you for your feedback.
Miguel,
Ah, I see where I went wrong. A small correction is needed:
Now gives:
and
Which meets your description in the original post.
I understand that that description apparently does not match with what you intended...
Luc
However, if your vector V always has the length of the value of the variable var, then you don't specifically need var, and the function can become simpler:
And you get:
Prime 4 file attached (You may need to force recalculation of the sheet, to update the symbolic results).
Success!
Luc