cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Function with a Vector variable

msantarsiero
1-Visitor

Function with a Vector variable

Hello,

usually I define function as function of variables. The latter being scalar.

How can I define a function with the variable being a vector?

example

function(p):=p(1)*x+p(2)

with p being a vector

this gives me error

Thank you

ACCEPTED SOLUTION

Accepted Solutions

Vectors are indexed starting at zero.  To address the first element in a vector requires a subscript using the keystroke "[".

Your sheet then will look as:

I have made the function use both p (a vector) and x.  You can put any vector (with at least two elements) into the function, and any value for x.

View solution in original post

3 REPLIES 3

function(p):=p[1*x+p[2

Note however that the default origin of vectors in Mathcad is 0, not 1, so unless you change the default then

function(p):=p[0*x+p[1

If that doesn't work, please post the worksheet.

Vectors are indexed starting at zero.  To address the first element in a vector requires a subscript using the keystroke "[".

Your sheet then will look as:

I have made the function use both p (a vector) and x.  You can put any vector (with at least two elements) into the function, and any value for x.

Thank you every body. quick and efficient.

Regards

Announcements

Top Tags