修改z_dsp.m相关函数以批量扫描线路参数和波形

修改TailCorr_Test的名字便于区分Verdi平台用的脚本和Windows平台

Signed-off-by: unknown <2779155576@qq.com>
This commit is contained in:
unknown 2024-12-30 14:06:53 +08:00 committed by futh0403
parent 98f6a41ec9
commit 418cbe0376
3 changed files with 268 additions and 131 deletions

View File

@ -1,5 +1,5 @@
%compare FIL with python script %compare FIL with python script
function diff_plot_py(fs,iir_out, Script_out,title1,title2,a,amp,edge) function diff_plot_py(fs,iir_out, Script_out,title1,title2,a,amp,edge,fileID)
% %
N = min(length(iir_out),length(Script_out)); N = min(length(iir_out),length(Script_out));
iir_out = iir_out(1:N); iir_out = iir_out(1:N);
@ -49,13 +49,7 @@ plot_p = @(x)[
text(n(x), diff(x)+diff(x)*0.1, ['(',num2str(n(x)),',',num2str(diff(x)),')'],'color','k'); text(n(x), diff(x)+diff(x)*0.1, ['(',num2str(n(x)),',',num2str(diff(x)),')'],'color','k');
]; ];
%
%plot_p(n_edge(1));%沿
%plot_p(n50(1)); %沿20ns
%plot_p(n1000(1)); %沿1us
ne(1) = 1; ne(1) = 1;
%plot_p(ne(end)); %
% [diff_max,R_mpos] = max(abs(diff));% % [diff_max,R_mpos] = max(abs(diff));%
% plot_p(R_mpos); % plot_p(R_mpos);
@ -63,16 +57,15 @@ ne(1) = 1;
if a(2) <= 5e-6 if a(2) <= 5e-6
plot_p(n_edge(1));%沿 plot_p(n_edge(1));%沿
% plot_p(R_mpos); % plot_p(R_mpos);
elseif a(2) > 5e-6 elseif a(2) == 20e-6
plot_p(n50(1)); %沿20ns plot_p(n50(1)); %沿20ns
plot_p(n1000(1)); %沿1us plot_p(n1000(1)); %沿1us
plot_p(ne(end)); % plot_p(ne(end)); %
fprintf("Falling edge of 20ns~40ns mean :%.4e\t std :%.4e\t",mean(diff(n20_40)),std(diff(n20_40))); fprintf(fileID,"Falling edge of 20ns~40ns mean :%.4e\t std :%.4e\t",mean(diff(n20_40)),std(diff(n20_40)));
fprintf("Falling edge of 1us~1.1us mean :%.4e\t std :%.4e\t",mean(diff(n1000_1100)),std(diff(n1000_1100))); fprintf(fileID,"Falling edge of 1us~1.1us mean :%.4e\t std :%.4e\t",mean(diff(n1000_1100)),std(diff(n1000_1100)));
% fprintf("The error after falling edge of 1us is:%.4e\t",diff(n1000(1))); % fprintf("The error after falling edge of 1us is:%.4e\t",diff(n1000(1)));
% fprintf("The time of erroe less than 1e-4 is :%.4e us\n",(n(ne(end))-n(n_edge(1)))); % fprintf("The time of erroe less than 1e-4 is :%.4e us\n",(n(ne(end))-n(n_edge(1))));
fprintf("The mean and std stably less than 1e-4 is :%.4e s\n",(n(n_common)-n(n_edge(1)))); fprintf(fileID,"The mean and std stably less than 1e-4 is :%.4e s\n",(n(n_common)-n(n_edge(1))));
end end

View File

@ -1,7 +1,22 @@
clc;clear;close all clc;clear;close all
% hdlsetuptoolpath('ToolName','Xilinx Vivado','ToolPath','D:\SoftWare\Xilinx\Vivado\2019.2\bin\vivado.bat'); % hdlsetuptoolpath('ToolName','Xilinx Vivado','ToolPath','D:\SoftWare\Xilinx\Vivado\2019.2\bin\vivado.bat');
%%
fs_L = 0.75e9; %
fs_H = 12e9; %
TargetFrequency = 3e9;
G = 1;
DownSample = 2;
simulink_time = 20e-6; %1.5*16e-6;1.5e-3
intp_mode = 3; %01224,38
dac_mode_sel = 0; %DAC012
route_num = 5; %线
env_num = 7; %
Ideal2Low = fs_H/(fs_L/2);
Ideal2Target = fs_H/TargetFrequency;
%% S21使
%%
% addpath(genpath('D:\Work\EnvData')); % addpath(genpath('D:\Work\EnvData'));
% addpath(genpath('D:\Work\EnvData\data-v2')); % addpath(genpath('D:\Work\EnvData\data-v2'));
% addpath(genpath('D:\Work\TailCorr_20241008_NoGit')); % addpath(genpath('D:\Work\TailCorr_20241008_NoGit'));
@ -12,43 +27,32 @@ py.importlib.reload(obj1);
cd("D:\Work\TailCorr_20241008_NoGit"); cd("D:\Work\TailCorr_20241008_NoGit");
obj2 = py.importlib.import_module('wave_calculation'); obj2 = py.importlib.import_module('wave_calculation');
py.importlib.reload(obj2); py.importlib.reload(obj2);
cd("D:\Work\TailCorr"); cd("D:\Work\TailCorr");
%%
fs_L = 0.75e9; %
fs_H = 12e9; %
TargetFrequency = 3e9;
Ideal2Low = fs_H/(fs_L/2);
Ideal2Target = fs_H/TargetFrequency;
G = 1;
DownSample = 2;
simulink_time = 20e-6; %1.5*16e-6;1.5e-3
intp_mode = 3; %01224,38
dac_mode_sel = 0; %DAC012
% %
amp_rect = 1.5e4; % amp_rect = 1.5e4;
%ns frontflatlagging0 % %ns frontflatlagging0
[front(1), flat(1), lagging(1)] = deal(50,100,7400);% 50,100,7400;100ns % [front(1), flat(1), lagging(1)] = deal(50,100,7400);% 50,100,7400;100ns
[front(2), flat(2), lagging(2)] = deal(50,4000,11500);% 50,4000,115004us % [front(2), flat(2), lagging(2)] = deal(50,4000,11500);% 50,4000,115004us
%
% for i = 1:2
% front_H(i) = front(i)*fs_H/1e9; flat_H(i) = flat(i)*fs_H/1e9; lagging_H(i) = lagging(i)*fs_H/1e9;
% wave_pre{i} = amp_rect*cat(2,zeros(1,front_H(i)),ones(1,flat_H(i)),zeros(1,lagging_H(i)));%
% end
for i = 1:2 %flattop
front_H(i) = front(i)*fs_H/1e9; flat_H(i) = flat(i)*fs_H/1e9; lagging_H(i) = lagging(i)*fs_H/1e9;
wave_pre{i} = amp_rect*cat(2,zeros(1,front_H(i)),ones(1,flat_H(i)),zeros(1,lagging_H(i)));%
end
%%% flattop
A = 1.5e4; A = 1.5e4;
[edge(1), length_flattop(1)] = deal(2,30);%nsfsn_L1length [edge(1), length_flattop(1)] = deal(2,30);%nsfsn_L1length
[edge(2), length_flattop(2)] = deal(4,30); [edge(2), length_flattop(2)] = deal(4,30);
[edge(3), length_flattop(3)] = deal(4,50); [edge(3), length_flattop(3)] = deal(4,50);
[edge(4), length_flattop(4)] = deal(6,50); [edge(4), length_flattop(4)] = deal(4,1000);
[edge(5), length_flattop(5)] = deal(100,10000);
for i = 1:4 for i = 1:5
[edge_H(i), length_H(i)] = deal(edge(i)*fs_H/1e9,length_flattop(i)*fs_H/1e9); [edge_H(i), length_H(i)] = deal(edge(i)*fs_H/1e9,length_flattop(i)*fs_H/1e9);
wave_pre{i+2} = flattop(A, edge_H(i), length_H(i), 1); wave_pre{i} = flattop(A, edge_H(i), length_H(i), 1);
end end
%%% acz %acz
amplitude = 1.5e4; amplitude = 1.5e4;
carrierFreq = 0.000000; carrierFreq = 0.000000;
@ -64,27 +68,47 @@ length_acz(2) = 50;
for i = 1:2 for i = 1:2
length_acz_H(i) = int32(length_acz(i)*fs_H/1e9); length_acz_H(i) = int32(length_acz(i)*fs_H/1e9);
wave_pre{i+6} = real(double(py.acz.aczwave(amplitude, length_acz_H(i), carrierFreq,carrierPhase, dragAlpha,thf, thi, lam2, lam3))); wave_pre{i+5} = real(double(py.acz.aczwave(amplitude, length_acz_H(i), carrierFreq,carrierPhase, dragAlpha,thf, thi, lam2, lam3)));
end end
% signalAnalyzer(wave_pre{2},'SampleRate',fs_H);
for i = 1:8 for i = 1:7
wave_pre{i} = cat(2,wave_pre{i},zeros(1,floor(simulink_time*fs_H))); % wave_pre{i} = cat(2,wave_pre{i},zeros(1,floor(simulink_time*fs_H))); %
wave_preL{i} = wave_pre{i}(1:Ideal2Low:end); % wave_preL{i} = wave_pre{i}(1:Ideal2Low:end); %
end end
% signalAnalyzer(HardwareMeanIntpDataAlign{1},'SampleRate',3e9); %%S21
amp_real{1}= [0.025 0.015 0.0002 0.2 0 0];
amp_imag{1}= [0 0 0 0 0 0];
time_real{1} = [-1/250, -1/650, -1/1600 -1/20 0 0];
time_imag{1} = [0 0 0 0 0 0];
%%%python amp_real{2}= [0.025 0.015 0.0002 0.2 0 0];
%S21 amp_imag{2}= [0 0 0 0 0 0];
amp_real = [0.025 0.015 0.0002 0.2 0 0]; time_real{2} = [-1/250, -1/650, -1/1600 -1/20 0 0];
amp_imag = [0 0 0 0 0 0]; time_imag{2} = [0 -1/300 -1/500 0 0 0];
time_real = [-1/250, -1/650, -1/1600 -1/20 0 0];
time_imag = [0 -1/300 -1/500 0 0 0];
amp_routing = amp_real + 1j*amp_imag; amp_real{3}= [0.025 0.009 0.0002 0.2 0 0];
time_routing = time_real + 1j*time_imag; amp_imag{3}= [0 0.012 0 0 0 0];
tau = -1./time_routing; time_real{3} = [-1/250, -1/650, -1/1600 -1/20 0 0];
time_imag{3} = [0 -1/300 -1/500 0 0 0];
amp_real{4}= [0.025 0.015 0.0002 0.2 0 0];
amp_imag{4}= [0 0 0 0 0 0];
time_real{4} = [-1/250, -1/2000, -1/1600 -1/20 0 0];
time_imag{4} = [0 -1/15 -1/50 0 0 0];
amp_real{5}= [0.025 0.009 0.0002 0.2 0 0];
amp_imag{5}= [0 0.012 0 0 0 0];
time_real{5} = [-1/250, -1/2000, -1/1600 -1/20 0 0];
time_imag{5} = [0 -1/15 -1/50 0 0 0];
for i = 1:5
amp_routing{i} = amp_real{1,i} + 1j*amp_imag{1,i};
time_routing{i} = time_real{1,i} + 1j*time_imag{1,i};
tau{i} = -1./time_routing{i};
end
%%python
convolve_bound = int8(3); convolve_bound = int8(3);
calibration_time = int32(20e3); calibration_time = int32(20e3);
@ -93,107 +117,227 @@ sampling_rateL = int64(fs_L/2);
sampling_rate = int64(fs_H); sampling_rate = int64(fs_H);
% %
for i = 1:8 for m = 1:route_num
wave_cal = cell(py.wave_calculation.wave_cal(wave_pre{i}, amp_real, amp_imag, time_real, time_imag, convolve_bound, calibration_time, cal_method, sampling_rate)); for n = 1:env_num
wave_revised{i} = double(wave_cal{1,1}); wave_cal = cell(py.wave_calculation.wave_cal(wave_pre{1,n}, amp_real{1,m}, amp_imag{1,m}, time_real{1,m}, time_imag{1,m}, convolve_bound, calibration_time, cal_method, sampling_rate));
wave_calL = cell(py.wave_calculation.wave_cal(wave_preL{i}, amp_real, amp_imag, time_real, time_imag, convolve_bound, calibration_time, cal_method, sampling_rateL)); wave_revised{m,n} = double(wave_cal{1,1});
wave_revisedL{i} = double(wave_calL{1,1}); wave_calL = cell(py.wave_calculation.wave_cal(wave_preL{1,n}, amp_real{1,m}, amp_imag{1,m}, time_real{1,m}, time_imag{1,m}, convolve_bound, calibration_time, cal_method, sampling_rateL));
wave_revisedL{m,n} = double(wave_calL{1,1});
end
alpha{m} = double(wave_calL{1,2});
beta{m} = double(wave_calL{1,3});
end end
% signalAnalyzer(wave_pre{1,1},'SampleRate',fs_H);
% %
alpha = double(wave_calL{1,2});
beta = double(wave_calL{1,3});
beta(5:6) = 0;
alpha_wideth=32; alpha_wideth=32;
beta_width=32; beta_width=32;
alphaFixRe = ceil((2^(alpha_wideth-1))*real(alpha)); %
alphaFixIm = ceil((2^(alpha_wideth-1))*imag(alpha)); for i = 1:route_num
betaFixRe = ceil((2^(beta_width-1))*real(beta)); alphaFixRe{i} = ceil((2^(alpha_wideth-1))*real(alpha{i}));
betaFixIm = ceil((2^(beta_width-1))*imag(beta)); alphaFixIm{i} = ceil((2^(alpha_wideth-1))*imag(alpha{i}));
betaFixRe{i} = ceil((2^(beta_width-1))*real(beta{i}));
%%%仿 betaFixIm{i} = ceil((2^(beta_width-1))*imag(beta{i}));
for i = 1:8
options=simset('SrcWorkspace','current');
sim('z_dsp',[0,simulink_time]);
sim2m = @(x)reshape(logsout.get(x).Values.Data,[],1);
dout0{i} = sim2m("dout0");
dout1{i} = sim2m("dout1");
dout2{i} = sim2m("dout2");
dout3{i} = sim2m("dout3");
N(i) = length(dout0{i});
cs_wave{i} = zeros(4*N(i),1);
cs_wave{i}(1:4:4*N) = dout0{i};
cs_wave{i}(2:4:4*N) = dout1{i};
cs_wave{i}(3:4:4*N) = dout2{i};
cs_wave{i}(4:4:4*N) = dout3{i};
HardwareMeanIntpData{i} = cs_wave{i};%
DownsamplingBy12GData{i} = wave_revised{i}(1:Ideal2Target:end);
[DownsamplingBy12GDataAlign{i},HardwareMeanIntpDataAlign{i},Delay(i)] = ...
alignsignals(DownsamplingBy12GData{i}(1:round(TargetFrequency*20e-6)),HardwareMeanIntpData{i}(1:round(TargetFrequency*20e-6)),"Method","xcorr");
end end
%% 仿
% signalAnalyzer(DownsamplingBy12GDataAlign{1},HardwareMeanIntpDataAlign{1},'SampleRate',3e9); for m = 1:route_num
for n = 1:env_num
optnons=simset('SrcWorkspace','current');
sim('z_dsp_FIL',[0,simulink_time]);
sim2m = @(x)reshape(logsout.get(x).Values.Data,[],1);
dout0{m,n} = sim2m("dout0");
dout1{m,n} = sim2m("dout1");
dout2{m,n} = sim2m("dout2");
dout3{m,n} = sim2m("dout3");
N = length(dout0{m,n});
cs_wave{m,n} = zeros(4*N,1);
cs_wave{m,n}(1:4:4*N) = dout0{m,n};
cs_wave{m,n}(2:4:4*N) = dout1{m,n};
cs_wave{m,n}(3:4:4*N) = dout2{m,n};
cs_wave{m,n}(4:4:4*N) = dout3{m,n};
HardwareMeanIntpData{m,n} = cs_wave{m,n};%
DownsamplingBy12GData{m,n} = wave_revised{m,n}(1:Ideal2Target:end);
[DownsamplingBy12GDataAlign{m,n},HardwareMeanIntpDataAlign{m,n},Delay(m,n)] = ...
alignsignals(DownsamplingBy12GData{m,n}(1:round(TargetFrequency*20e-6)),HardwareMeanIntpData{m,n}(1:round(TargetFrequency*20e-6)),"Method","xcorr");
end
end
% signalAnalyzer(wave_revised,'SampleRate',3e9);
%% %%
close all; close all;
Amp = 1.5e4; Amp = 1.5e4;
FallingEdge = [ FallingEdge = [
150e-9,4050e-9,...% % 150e-9,4050e-9,...%
30e-9,30e-9,50e-9,50e-9,...%flattop 30e-9,30e-9,50e-9,1000e-9,10000e-9,...%flattop
30e-9,50e-9%acz 30e-9,50e-9%acz
]; ];
name = [ name = [
"rect_100ns_校正后的波形_下降沿后10ns.fig","rect_100ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后10ns",...
"rect_4us_校正后的波形_下降沿后10ns.fig","rect_4us_校正后的波形_下降沿后1us.fig"; "第一组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后10ns",...
"flattop_上升沿2ns_持续时间30ns_校正后的波形_下降沿后10ns.fig","flattop_上升沿2ns_持续时间30ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后10ns",...
"flattop_上升沿4ns_持续时间30ns_校正后的波形_下降沿后10ns.fig","flattop_上升沿4ns_持续时间30ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后10ns",...
"flattop_上升沿4ns_持续时间50ns_校正后的波形_下降沿后10ns.fig","flattop_上升沿4ns_持续时间50ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后10ns",...
"flattop_上升沿6ns_持续时间50ns_校正后的波形_下降沿后10ns.fig","flattop_上升沿6ns_持续时间50ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_acz_持续时间30ns_下降沿后10ns",...
"acz_持续时间30ns_校正后的波形_下降沿后10ns.fig","acz_持续时间30ns_校正后的波形_下降沿后1us.fig"; "第一组S21参数_acz_持续时间50ns_下降沿后10ns";
"acz_持续时间50ns_校正后的波形_下降沿后10ns.fig","acz_持续时间50ns_校正后的波形_下降沿后1us.fig"; "第二组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后10ns",...
"第二组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后10ns",...
"第二组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后10ns",...
"第二组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后10ns",...
"第二组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后10ns",...
"第二组S21参数_acz_持续时间30ns_下降沿后10ns",...
"第二组S21参数_acz_持续时间50ns_下降沿后10ns";
"第三组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后10ns",...
"第三组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后10ns",...
"第三组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后10ns",...
"第三组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后10ns",...
"第三组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后10ns",...
"第三组S21参数_acz_持续时间30ns_下降沿后10ns",...
"第三组S21参数_acz_持续时间50ns_下降沿后10ns";
"第四组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后10ns",...
"第四组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后10ns",...
"第四组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后10ns",...
"第四组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后10ns",...
"第四组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后10ns",...
"第四组S21参数_acz_持续时间30ns_下降沿后10ns",...
"第四组S21参数_acz_持续时间50ns_下降沿后10ns";
"第五组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后10ns",...
"第五组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后10ns",...
"第五组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后10ns",...
"第五组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后10ns",...
"第五组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后10ns",...
"第五组S21参数_acz_持续时间30ns_下降沿后10ns",...
"第五组S21参数_acz_持续时间50ns_下降沿后10ns";
"第一组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后1us",...
"第一组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后1us",...
"第一组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后1us",...
"第一组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后1us",...
"第一组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后1us",...
"第一组S21参数_acz_持续时间30ns_下降沿后1us",...
"第一组S21参数_acz_持续时间50ns_下降沿后1us";
"第二组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后1us",...
"第二组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后1us",...
"第二组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后1us",...
"第二组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后1us",...
"第二组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后1us",...
"第二组S21参数_acz_持续时间30ns_下降沿后1us",...
"第二组S21参数_acz_持续时间50ns_下降沿后1us";
"第三组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后1us",...
"第三组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后1us",...
"第三组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后1us",...
"第三组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后1us",...
"第三组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后1us",...
"第三组S21参数_acz_持续时间30ns_下降沿后1us",...
"第三组S21参数_acz_持续时间50ns_下降沿后1us";
"第四组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后1us",...
"第四组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后1us",...
"第四组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后1us",...
"第四组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后1us",...
"第四组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后1us",...
"第四组S21参数_acz_持续时间30ns_下降沿后1us",...
"第四组S21参数_acz_持续时间50ns_下降沿后1us";
"第五组S21参数_flattop_上升沿2ns_持续时间30ns_下降沿后1us",...
"第五组S21参数_flattop_上升沿4ns_持续时间30ns_下降沿后1us",...
"第五组S21参数_flattop_上升沿4ns_持续时间50ns_下降沿后1us",...
"第五组S21参数_flattop_上升沿4ns_持续时间1000ns_下降沿后1us",...
"第五组S21参数_flattop_上升沿100ns_持续时间10000ns_下降沿后1us",...
"第五组S21参数_acz_持续时间30ns_下降沿后1us",...
"第五组S21参数_acz_持续时间50ns_下降沿后1us";
]; ];
Delay_mode = mode(Delay);
for i = 1:8 Delay_mode = mode(Delay,'all');
start_time(i) = abs(Delay_mode)/(TargetFrequency/1e9)*1e-9;%3GHz31ns fileID = fopen('20241226_output.txt', 'w');
edge_Align(i) = FallingEdge(i) + start_time(i); if fileID == -1
tmp(i) = edge_Align(i) + 10e-9; disp('');
a{i} = [start_time(i)-5e-9 tmp(i)];%[1/fs_H 50e-9];[50e-9 1.5e-6],[500e-9+10e-9 tmp-20e-9] else
b{i} = [tmp(i) 10e-6];
fig1 = figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]);
diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{i}', DownsamplingBy12GDataAlign{i}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',a{i},Amp,edge_Align(i));
title(name(i,1),Interpreter="none");
% savefig(name(i,1));
fig2 = figure('Units','normalized','Position',[0.000390625,0.034027777777778,0.49921875,0.422916666666667]);
diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{i}', DownsamplingBy12GDataAlign{i}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',b{i},Amp,edge_Align(i));
title(name(i,2),Interpreter="none");
% savefig(name(i,2));
end end
for m = 1:route_num
for n = 1:env_num
start_time(n) = abs(Delay_mode)/(TargetFrequency/1e9)*1e-9;%3GHz31ns
edge_Align(n) = FallingEdge(n) + start_time(n);
tmp(n) = edge_Align(n) + 10e-9;
a{n} = [start_time(n)-5e-9 tmp(n)];%[1/fs_H 50e-9];[50e-9 1.5e-6],[500e-9+10e-9 tmp-20e-9]
b{n} = [tmp(n) 20e-6];
fig1 = figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]);
diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{m,n}', DownsamplingBy12GDataAlign{m,n}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',a{n},Amp,edge_Align(n),fileID);
title(name(m,n),Interpreter="none");
savefig(name(m,n));
fig2 = figure('Units','normalized','Position',[0.000390625,0.034027777777778,0.49921875,0.422916666666667]);
diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{m,n}', DownsamplingBy12GDataAlign{m,n}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',b{n},Amp,edge_Align(n),fileID);
title(name(m,n),Interpreter="none");
savefig(name(m+5,n));
end
end
fclose(fileID);
%% S21 %% S21
t = 0:1/(1e2):10000; t = 0:1/(1e2):10000;
for m = 1:route_num
for i = 1:1:length(amp_routing) for n = 1:1:length(amp_routing{1,m})
S21_time(:,i) = amp_routing(i)*exp(time_routing(i)*t); S21_time{m}(:,n) = amp_routing{1,m}(n)*exp(time_routing{1,m}(n)*t);
end
figure
plot(t*1e-9,real(sum(S21_time{m},2)));
grid on
title("s(t)");
end end
figure % savefig("S21参数");
plot(t*1e-9,real(sum(S21_time,2)));
grid on
title("s(t)");
savefig("S21参数");
% signalAnalyzer(real(sum(S21_time,2)),'SampleRate',1e11);%1ns % signalAnalyzer(real(sum(S21_time,2)),'SampleRate',1e11);%1ns
% rmpath(genpath('D:\Work\EnvData')); % rmpath(genpath('D:\Work\EnvData'));
% rmpath(genpath('D:\Work\EnvData\data-v2')); % rmpath(genpath('D:\Work\EnvData\data-v2'));
% rmpath(genpath('D:\Work\TailCorr_20241008_NoGit')); % rmpath(genpath('D:\Work\TailCorr_20241008_NoGit'));
%% %%
cd("D:\Work\TailCorr\仿真结果\20241101_125M八倍内插至1G_第1组S21参数") for m = 1:35
for i = 1:8 figure(2*m-1)
close all figure(2*m)
open(name(i,1)); pause(0.2);
open(name(i,2));
pause()
end end
%%
% cd("D:\Work\TailCorr\仿真结果\20241101_125M八倍内插至1G_第1组S21参数");
close all
for n = 1:route_num
for m = 1:env_num
open(strcat(name(n,m),'.fig'));
open(strcat(name(n+5,m),'.fig'));
pause();
end
end
%%
close all
fid = fopen('20241226_output.txt','r');
data = textscan(fid,'Falling edge of 20ns~40ns mean :%s std :%s Falling edge of 1us~1.1us mean :%s std :%s The mean and std stably less than 1e-4 is :%s s');
fclose(fid);
data{1} = cellfun(@str2num,data{1});
data{2} = cellfun(@str2num,data{2});
data{3} = cellfun(@str2num,data{3});
data{4} = cellfun(@str2num,data{4});
data{5} = cellfun(@str2num,data{5});
title_name = ["下降沿后20ns~40ns误差的平均值","下降沿后20ns~40ns误差的标准差","下降沿后1us~1.1us误差的平均值","下降沿后1us~1.1us误差的标准差","加窗参数"];
err_threshold = [1e-3 1e-3 1e-4 3e-4 5e-5];
figure()
tiledlayout('flow','TileSpacing','tight')
colors = lines(route_num);
for m = 1:5
nexttile
hold on
for i = 1:(route_num)
idx = (i-1)*(length(falling20_mean)/route_num) + 1 : i*(length(falling20_mean)/route_num);
plot(idx,abs(data{m}(idx)),'-o','Color', colors(i, :));
end
yline(err_threshold(m),'--r');
title(title_name(m));
set(gca,'YScale','log');
end
%%
figure()
semilogy(abs(falling20_mean),'-o');