Reputation: 193
This is simple, but for some reason I can't find the solution anywhere on the Internet. I have a vector function in Matlab:
E(s) = [E_1(s),E_2(s),E_3(s)]
I want to be able to index it, so normally in Matlab you would use E(1)
, for the first element. However this just evaluates the vector at s
equals 2
. E(s)(1)
also gives an error.
Here's my code for reference.
Upvotes: 3
Views: 1324
Reputation: 18484
You have a symbolic function that returns a vector. Type whos
and you'll see that the class of E
is symfun
. Unfortunately, I don't think that you can directly index into a symbolic function. However, you can convert it into a symbolic expression (class sym
) simply by setting it equal to a new variable and passing in your symbolic variable s
Es = E(s);
Now you should be able to evaluate Es(1)
, Es(2)
, and Es(3)
as you wanted.
Upvotes: 4
Reputation: 495
If I understand you correctly, your only hope is to use the command "eval." Type "help eval" and see if that's what you need.
Upvotes: 0