Hello. I need your help. I am trying to use the optimazation function 'fminsearch' to find 8 unkown values. The function M file which I made is,

function y_1=opti_real(x)

global Ra Rb La Lb Ga Gb Ca Cb Zc Zc_A Gamma Z Y wm R L G C Frequency

wm=2*pi*Frequency;

syms Ra Rb La Lb Ga Gb Ca Cb real

wm=2*pi*Frequency;

R=[Ra, Rb, Rb; Rb, Ra, Rb; Rb, Rb, Ra;]; L=[La, Lb, Lb; Lb, La, Lb; Lb, Lb, La;]; G=[Ga, Gb, Gb; Gb, Ga, Gb; Gb, Gb, Ga;]; C=[Ca, Cb, Cb; Cb, Ca, Cb; Cb, Cb, Ca;];

Z=R+j*wm(1,1)*L; Y=G+j*wm(1,1)*C;

Gamma=sqrtm(Z*Y); Zc=Gamma*inv(Y);

Ra=x(1); Rb=x(2); La=x(3); Lb=x(4); Ga=x(5); Gb=x(6); Ca=x(7); Cb=x(8);

y_1=abs(real(Zc_A)-real(Zc));

where Ra, Rb, La, Lb, Ga, Gb, Ca, Cb are unkown parameters. Frquency and Zc_A are calculated values from main code. Zc_A is a 3 by 3 matrix that contains complex numbers. The main code to find the values of Ra, Rb, La, Lb, Ga, Gb, Ca, Cb is,

x=[R_open(1,1), 0, L_open(1,1), 0, G_open(1,1), 0, C_open(1,1), 0]; bb=fminsearch(@opti_real, x);

where, R_open(1,1)… are calculated real values in main code. After I run the main code, the error message is displayed as follows:

DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use VPA.

can you explain the problem and fix my code please?

## Best Answer