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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. 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