I will be very happy if you can help me. I am trying to get the effective mu and epsilon values of the metamaterial unit cell. Although I am trying very hard, the values are inconsistent from the article. Can you help me? Thanks for your help. This is my code
clear all;
S11_gen = readtable('5g_s11_abs.txt'); % S11: frekans/Hz real
S11_phs = readtable('5g_s11_phs.txt'); % S11: frekans/Hz imag
S21_gen = readtable('5g_s21_abs.txt'); % S11: frekans/Hz real
S21_phs = readtable('5g_s21_phs.txt'); % S11: frekans/Hz imag
S11_phs2 = deg2rad(S11_phs{:,2});
S21_phs2 = deg2rad(S21_phs{:,2});
Frequency_S11 = S11_gen{:, 1}; % S11 frekans sütunu (Hz)
S11=S11_gen{:,2}.*(cos(S11_phs2)+1i*sin(S11_phs2));
Frequency_S21 = S21_gen{:, 1}; % S21 frekans sütunu (Hz)
S21=S21_gen{:,2}.*(cos(S21_phs2)+1i*sin(S21_phs2));
% Frekansların eşleştiğini kontrol etme
if ~isequal(Frequency_S11, Frequency_S21)
error('S11 ve S21 frekans sütunları eşleşmiyor! Lütfen dosyaları kontrol edin.');
end
% Frekans verisi (ortak frekans)
Frequency = Frequency_S11*1e9;
% NRW Algoritması
c = 3e8; % Işık hızı (m/s)
d = 0.27e-3; % Malzeme kalınlığı (m)
k0 = 2 * pi .* Frequency / c; % Dalga sayısı (1/m)
z=((((1+S11).^2)-S21.^2)./(((1-S11).^2)-S21.^2)).^0.5;
tmp=(z-1)./(z+1);
exp=S21./(1-S11.*tmp);
n=(imag(log(exp))-1i.*real(log(exp)))./(k0*d);
epsilon=n./z;
mu=n.*z;
% DNG (Double Negative) frekanslarını belirleme
DNG_indices = find(real(epsilon) < 0 & real(mu) < 0); % DNG koşullarını sağlayan indeksler
DNG_frequencies = Frequency(DNG_indices); % DNG frekansları (Hz)
% Sonuçları görüntüleme
disp('DNG Olunan Frekanslar (GHz):');
disp(DNG_frequencies / 1e9); % GHz cinsinden frekanslar
% Grafikler
figure;
subplot(2, 1, 1);
plot(Frequency / 1e9, real(epsilon), 'b', 'LineWidth', 1.5); hold on;
% plot(Frequency / 1e9, imag(epsilon), 'r', 'LineWidth', 1.5);
xlabel('Frequency (GHz)');
ylabel('Permittivity (\epsilon)');
legend('Real(\epsilon)', 'Imag(\epsilon)');
title('Effective Permittivity');
grid on;
subplot(2, 1, 2);
plot(Frequency / 1e9, real(mu), 'b', 'LineWidth', 1.5); hold on;
% plot(Frequency / 1e9, imag(mu), 'r', 'LineWidth', 1.5);
xlabel('Frequency (GHz)');
ylabel('Permeability (\mu)');
legend('Real(\mu)', 'Imag(\mu)');
title('Effective Permeability');
grid on;