Guuk
Guuk

Reputation: 609

Access to submatrices in symbolic writing (matlab)

Considering a matrix defining using Symbolic Toolbox:

   syms X Y
   f(X,Y)=[1 X X^2; 1 Y Y^2];

we obtain:

   >> f(X,Y)

   ans =

   [ 1, X, X^2]
   [ 1, Y, Y^2]

How can we extract only the second row of this matrix? Is the indexing scheme different in this case (f(X,Y)(2,:))?

Upvotes: 1

Views: 787

Answers (1)

Daniel
Daniel

Reputation: 36710

You have defined a (scalar 1x1) symfun returning a matrix, there is no indexing directly on this symfun. Extrat the symbolic term first:

%convert symfun to sym
f=f(X,Y)
%now you can use indices
f=f(1:2,3)
%convert back to symfun
f(X,Y)=f

Upvotes: 1

Related Questions