Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi all,
What I am tryin to achieve is to pass elements of a matrix as a variable to a function but I get the good old 'A name is required here.', please see the attachement for the snippet of my sheet. I hope experienced users can point me to the right direction.
Thanks.
Solved! Go to Solution.
Because "er1[x,x" has a numeric value mathcad does not have a valid parameter to the function
What it is trying to interpret is similar to
f(2,2) := 2+2
It needs the definition to be of the form
f(a,b) := a+b
then when you call the function later
f(2,2) = it replaces the parameters a& b with the given values & return the required answer
As the snip is written , you don't need to pass any parameters, the function can access the data directly.
If , however the whole program needs the flexibility you can re-write the function in a form as attached.
regards
Andy
I want to be able to pass each element of the matrix as variables of the function, in your example you are passing the whole matrix as a variable, am I missing something ?
Is there a reason why you want to pass all the elements individually, rather than the whole lot at once?
To pass them individually you have to give them all separate names (i.e. not using true subscripts).
Alan
Because "er1[x,x" has a numeric value mathcad does not have a valid parameter to the function
What it is trying to interpret is similar to
f(2,2) := 2+2
It needs the definition to be of the form
f(a,b) := a+b
then when you call the function later
f(2,2) = it replaces the parameters a& b with the given values & return the required answer
As the snip is written , you don't need to pass any parameters, the function can access the data directly.
If , however the whole program needs the flexibility you can re-write the function in a form as attached.
regards
Andy