%% Impedance calculation

clear, close all;
n = 500;
e = 4.5;
t = 0.001;
w = linspace(.01,.5,n);
h = linspace( .1,.2,n);
imp = zeros(n,n);

for i=1:n
    for j=1:n
        imp(i,j) = impedance(h(i),w(j),e);
    end
end

[h,w] = meshgrid(h,w);

figure(1)
surfc(h,w,imp,'EdgeColor','none');
xlabel('height of the glass in inches')
ylabel('width of the trace in inches')
zlabel('Impedence in Ohms')
grid on

clear h w e imp

e = 9.5;
h = 0.1;
w = linspace(.01,.5,n);
imp = zeros(1,n);
for i=1:n
        imp(i) = impedance(h,w(i),e);
end

figure('Name','Impedance ceramic','NumberTitle','off')
plot(w,imp);
xlabel('Width of the strip in inches')
ylabel('Impedance in ohms')
title('Impedance of .1in ceramic plate strilines function of strip width')
grid on

clear h w e imp

e = 4.6;
h = 0.1;
w = linspace(.01,.5,n);
imp = zeros(1,n);
for i=1:n
        imp(i) = impedance(h,w(i),e);
end

figure('Name','Impedance glass','NumberTitle','off')
plot(w,imp);
xlabel('Width of the strip in inches')
ylabel('Impedance in ohms')
title('Impedance of .1in glass plate function of strip width')
grid on

data = csvread('Data.csv');

figure('Name','Odd and Even Impedance','NumberTitle','off')
hold on
plot(data(:,1),data(:,2),'Color',[1,0,0]         ,'LineWidth',2);
plot(data(:,1),data(:,3),'Color',[0.21,0.78,0.21],'LineWidth',2);
hold off
xlabel('Width of the gap in inches')
ylabel('Impedance in ohms')
legend('Even mode Impedance','Odd mode Impedance')
title('Impedance of .1in glass plate function of strip width')
grid on
