Complex number error (number will be an array)
Show older comments
The values in last line is definetely a number(complex).
But, if I put [number], it will be an array(1,2). (Example1 is a number, Example2 is an array)
Why is this happend? How could I figure out?
clear
clc
close all
%%constant
c = 299792458;
f = 34.3e9;
mu0 = 4*pi*1e-7;
eps0 = 1/(c^2*mu0);
eps_sub = 11.256;
n_sub = sqrt(eps_sub);
mu_sub = 1;
eps_sub = 11.256;
lambda0 = c/f;
beta0 = 2*pi/lambda0;
beta_sub = beta0*n_sub;
alpha_sub = 0.01*beta_sub;
gamma = alpha_sub + 1i*beta_sub;
Z_sub = sqrt((mu0*mu_sub)/(eps0*eps_sub));
eta0 = sqrt(mu0/eps0);
d = lambda0/14;
theta = linspace(-1.5*pi, 2.5*pi,10);
w = 2*pi*f;
i=1;
%% equation
ABCD_TL = [cos(beta_sub*d), 1i*Z_sub*sin(beta_sub*d) ; 1i*sin(beta_sub*d)/Z_sub, cos(beta_sub*d)];
S11 = 0;
S12 = exp(1i*theta(i));
S22 = 0;
S21 = exp(1i*theta(i));
A_S = ((1+S11)*(1-S22) + S12*S21)/(2*S21);
B_S = eta0*((1+S11)*(1+S22) - S12*S21)/(2*S21);
C_S = (1/eta0)*((1-S11)*(1-S22) - S12*S21)/(2*S21);
D_S = ((1-S11)*(1+S22) + S12*S21)/(2*S21);
A=ABCD_TL(1,1);
B=ABCD_TL(1,2);
C=ABCD_TL(2,1);
D=ABCD_TL(2,2);
LC = [1;1;1;1];
Example1 = A^2 + B*C + A*B*(1/(1i*(w*LC(3) - 1/(w*LC(4))))) +(1/(1i*(w*LC(1) - 1/(w*LC(2)))))*(A*B + B^2*(1/(1i*(w*LC(3) - 1/(w*LC(4))))) + B*D) - A_S
Example2 = [A^2 + B*C + A*B*(1/(1i*(w*LC(3) - 1/(w*LC(4))))) +(1/(1i*(w*LC(1) - 1/(w*LC(2)))))*(A*B + B^2*(1/(1i*(w*LC(3) - 1/(w*LC(4))))) + B*D) - A_S]
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!