1

What I have:

syms X Y funcF = [ (X.^2 + Y.^2 + X -4), (Y*cos(X) + X*Y.^3 - 1) ] z0 = [0.5, 2] 

Say I want to pass z0 to funcF, I'm not sure how to do this. (My knowledge of matlab isn't the greatest)

So I'm currently trying:

funcF = funcF(z0) 

Essentially, I want it to print something like this:

[#1 #2] 
1
  • 1
    Don't understand the downvotes. The OP has clearly show what he/she has tried and where the difficulties are. Commented Apr 3, 2015 at 19:05

1 Answer 1

2

Because that expression is symbolic, you need to use subs. subs replaces symbolic variables with whatever you want... and that includes numbers. Also, because this is a symbolic expression (thanks Nasser), there is no need for point-by-point operators (i.e. .^). You can remove these and use the normal scalar operators.

As such, you want to replace X and Y in the expression with the corresponding values in z0:

>> syms X Y; >> funcF = [ (X^2 + Y^2 + X -4), (Y*cos(X) + X*Y^3 - 1) ]; >> out = subs(funcF, {'X','Y'}, z0) out = [ 3/4, 2*cos(1/2) + 3] 
Sign up to request clarification or add additional context in comments.

6 Comments

the "." is not needed, since these are syms and not numerics. Actually I do not think the "." is even supported for syms as in numerical vectors. It works above because it seems it was just ignored. But it is not needed.
@Nasser - I simply copied and pasted what the OP put in his/her statement, but you are correct.
@user2925439 - no worries. If it works, consider accepting my answer. This means that you no longer need help in this particular question, and the rest of us can move on to answer other questions. Good luck!
@user2925439 - OH! that's easy. Go to the top of my post, and at the left of it, there's a checkmark icon just underneath the up and down voting arrows. Click on that. Thanks and good luck! :)
@user2925439 - Also make sure you go around your previous questions and accept some of those answers too. I took a quick look and there are a few questions with some solid answers that helped you out. Pay it forward and accept their answers too! :).
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.