## How can I subs 2 symbolic vectors in 1 comand?

### Pedro González López (view profile)

on 16 Feb 2019
Latest activity Answered by Star Strider

on 16 Feb 2019

### Star Strider (view profile)

HI!
I have this code:
syms a b c d
X=[a,b]; Y=[c,d];
Z=[X;Y];
X0=[1,2]; Y0=[3,4];
Can I subs "X0" and "Y0" in "Z" without linking "X" and "Y"?
I mean something like (warning, totally invented) subs(Z,{X Y},{X0,Y0})
thanks ^^

### Star Strider (view profile)

on 16 Feb 2019

You defined ‘Z’ to require 4 different arguments, so the substitution has to match them, either using subs or using ‘Z’ as a function:
syms a b c d
X=[a,b]; Y=[c,d];
Z=[X;Y];
X0=[1,2]; Y0=[3,4];
Zs = subs(Z,{a,b,c,d},{X0(1),X0(2),Y0(1),Y0(2)})
syms a b c d
X=[a,b]; Y=[c,d];
Z(X,Y)=[X;Y];
X0=[1,2]; Y0=[3,4];
Zs = Z(X0(1),X0(2),Y0(1),Y0(2))
However if you defined ‘Z’ differently, these would work:
syms a b c d
X=a; Y=c;
Z=[X;Y];
X0=[1,2]; Y0=[3,4];
Zs = subs(Z,{X,Y},{X0,Y0})
syms a b c d
X=a; Y=c;
Z(X,Y)=[X;Y];
X0=[1,2]; Y0=[3,4];
Zs = Z(X0,Y0)

on 16 Feb 2019