1

I'm trying to do something like

f = [x+1 y+2]
values = [1 2]
f(values) = [2 4]

(not proper syntax)

f(values) only works for taking one variable?

1

1 Answer 1

1

Try this:

f = {@(x) (x+1); @(y) (y+2)}; %//create a cell array of your function handlers
values = [1 2];

%//convert your input values to a cell array
length = numel(values);
v = mat2cell( values, 1, ones(length,1) ).' ; 

%// f(v)
results = cellfun(@(x,y) x(y), f, v);
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.