1

I have a function F that is a vector of functions in n variables. For example, consider the following:

syms x y z f(f1,f2,f3) f1(x,y,z) f2(x,y,z) f3(x,y,z)

X0 = [1 0 1 0]';

f1(x,y,z) =  x+y+2;
f2(x,y,z) =  w-5*x+z^2-4;
f3(x,y,z) =  2*x+y^2-z-12;


F = vertcat(f1, f2, f3)

Here, F is a vector of three functions in three variables. In the case I am considering, I want F to be considered n equations in n variables.

I want to take a vector of scalars the length of F, like the following:

X = [1 2 3]';

and evaluate F at this vector. So something like:

F(X(1),X(2),X(3))

However, I need a way to write that without knowing n. I could find n by writing

dims = size(X);

But that doesn't solve how I parametrically evaluate F at X. Is there a way to do this?

1
  • Any specific reason you’re using symbolic math here? The example you give does not require it. This would be much simpler using normal numeric syntax. Commented Oct 14, 2019 at 1:22

1 Answer 1

1

If you don't mind using cells instead of arrays, you can replace X = [1 2 3]' by X = {1 2 3} (the transpose is not necessary) and F(x(1),x(2),x(3)) by F(X{:}).

Sign up to request clarification or add additional context in comments.

2 Comments

I'll look into this solution and let you know how it goes. Thanks!
It works! I had to also define a numerical array x to store iterative solutions for what X contains in my larger problem, but this solution allowed the indexing to work. Thanks for your help.

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.