0

Supposing I have the function test which takes arguments x and y.

Now, I have

myVector = 1:5

and

myVar = 6

I want to run test several times such as x takes all the values present in myVector and y is always myVar:

Ie : test(1,6) test(2,6) ... test(5,6)

my original ideas was to use arrayfunc, however, from what I see arrayfunc takes as paramters the function I want to call and a vector of values.

Any suggestions?

Dario

1 Answer 1

3

You can do it with an anonymous function that takes the element of myVector and passes it to your test function:

arrayfun(@(n) test(n,myVar), myVector)
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.