Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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
Solved! Go to Solution.
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.
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