MATLAB: I am getting this error “The following error occurred converting from sym to double: DOUBLE cannot convert the input expression into a double array.” for this code.Please help me.

syms Vo Req Cin L rL Co R D
A=[-(rL/L) 1/L -(1-D)/L; -(1/Cin) -1/(Req*Cin) 0; -(1-D)/Co 0 -1/(R*Co)]; B=[Vo/L; 0; -(Vo*(1-D))/L]; C=[0 1 0]; D=0; [num,den]=(ss2tf(A,B,C,D)); a=tf(num,den);

Best Answer

Hi,
using symbolic values isnt possible for your purpose. You can choose between 2 options:
1.) use
preal
command to declare your parameters as tunable in your model. In order to do this change your code this way (initial values = 1 for all - your turn finding meaningful values):
Vo = realp('Vo',1);
Req = realp('Req',1);
Cin = realp('Cin',1);
L = realp('L',1);
rL = realp('rL',1);
Co = realp('Co',1);
R = realp('R',1);
D = realp('D',1);
A=[-(rL/L) 1/L -(1-D)/L;
-(1/Cin) -1/(Req*Cin) 0;
-(1-D)/Co 0 -1/(R*Co)];
B=[Vo/L; 0; -(Vo*(1-D))/L];
C=[0 1 0];
D=0;
state_space = ss(A,B,C,D)
This gives you a state space model with all parameters tunable:
state_space =
Generalized continuous-time state-space model with 1 outputs, 1 inputs, 3 states, and the following blocks:
Cin: Scalar parameter, 2 occurrences.
Co: Scalar parameter, 2 occurrences.
D: Scalar parameter, 3 occurrences.
L: Scalar parameter, 5 occurrences.
R: Scalar parameter, 1 occurrences.
Req: Scalar parameter, 1 occurrences.
Vo: Scalar parameter, 2 occurrences.
rL: Scalar parameter, 1 occurrences.
Type "ss(state_space)" to see the current value, "get(state_space)"
Disadvantage:
This can not be transferred into a transfer function. All operations regarding tf's should be also possible with a state space model - so i assume this is what you should do.
2.) give discrete values to your variables and build your transfer function like you did.
Best regards
Stephan
Related Question