How to input a vector into a multi-variable symbolic function - Error using symfun/subsref

Hi,
I'm trying to generate a series of vectors using a recursive function. Say my initial vector is [1 1], and my function is f((x,y))=(x+1,y+2).
I've defined my function as follows:
syms x y;
f=symfun([x+1 y+2],[x y]);
I then want to apply f to the initial vector, but when I try to use
f([1 1])
I get the error
Error using symfun/subsref
Symbolic function expected 2 inputs and received 1.
How can I apply f to this vector? The issue is that the vector's dimensions vary, so I can't explicitly write
f(x1, x2, ... xn)
Thanks in advance!

Respuestas (1)

okay it's a bit late but maybe someone else could use this
try this:
subs(symbolic_expression, list_of_variables, list_of_values)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Jun. de 2017

Respondida:

el 18 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by