I want to splice a vector into a function call, but I can't find a way to do this. Is it possible?
To expand on what I mean, say we have the vector x
of length n
and a function f
that takes n
arguments. I want to be able to call f(x(1), x(2), ..., x(n))
by calling something like f(x)
or f(splice(x))
. If x
were a cell array instead of a vector, calling f(x{:})
would get the desired result; it only seems reasonable that there would be some equivalent for when x
is a vector.
I'm hoping for some operator or function that I'm missing. I could just call y = num2cell(x)
followed by f(y{:})
, but this is not really what I'm looking for.
x(:)
work? Or if it's a column vector usex(:)'
. – Thornum2cell
route is exactly what you should be looking for. – Jonasx
,x(:)
is always a column vector. In particular, ifx
is already a vector, thenx(:)
is just the same vector (though perhaps transposed). – zroth