Skip to main content
1-Visitor
January 8, 2013
Solved

Element of a matrix as a variable of a function ?

  • January 8, 2013
  • 4 replies
  • 2387 views

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.

Best answer by AndyWesterman

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

4 replies

19-Tanzanite
January 8, 2013

Do it as in the attached.

Alan

yeet1-VisitorAuthor
1-Visitor
January 8, 2013

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 ?

19-Tanzanite
January 8, 2013

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