Reputation: 5086
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
Upvotes: 0
Views: 153
Reputation: 112659
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)
Upvotes: 3