0

I have a function handle e.g.

x = @(x)[2*x;x^2;x-13;3*x+2]

Now I can evaluate all functions for a given points say x(1) giving as a result 2,1,12,5. But I would like to provide it with 4 points like so x(1,2,13,1) and get 2,4,0,5. I know I could write my own function to do this, but this seems fairly basic and I suppose a solution exists, but I don't know how to find it in the documentation.

2

1 Answer 1

1

A solution can be like this:

y = @(x)[2*x(1);x(2)^2;x(3)-13;3*x(4)+2]

Then evaluate the function like the following:

y([1 2 3 4])

Then you will get the following result:

[2;4;-10;14]

The second solution would be such as mentioned by @Andrei in the comment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.