MATLAB: Transfer function

transfer function

I am new to matlab'plz help me, I am trying to get a Transfer function v2/y, when i tried getting v1/y it worked, here it is: syms s ,'a','b','c','d','k'; S = solve('y=v1*(c+d+a)-v2*c','c*(s*v1-s*v2)=b*s*v2+k*v2'); S = [S.v1 /S.y] but when i try to substitute v1 for v2(in the last line) i get the an error. why as that? is there any better way of doing it? tnx.

Best Answer

S =
v1: [1x1 sym]
y: [1x1 sym]
There no v2 in the solution so S.v2 gives the error
If you want S.v2
syms s a b c d k
S = solve('y=v1*(c+d+a)-v2*c','c*(s*v1-s*v2)=b*s*v2+k*v2','v2','y');
S = [S.v2 /S.y]
Please note that the way you were defining the symbolic variables was working fine but could be simpler like in my code.
Also note that I added 'v2' and 'y' to the solve function, this way I'm telling that I want to get the solution for the v2 and y variables, if you don't specify the variables the solver will find them for you just like in your code, but it might not give what you wanted.