TailCorr/script_m/diff_plot.m

34 lines
799 B
Mathematica
Raw Normal View History

2024-10-08 17:58:26 +08:00
function diff_plot(iir_out, Script_out,leg1,leg2,a)
2024-11-04 19:09:41 +08:00
N = min(length(iir_out),length(Script_out));
iir_out = iir_out(1:N);
Script_out = Script_out(1:N);
2024-10-08 17:58:26 +08:00
n = 0:1:N-1;
diff = iir_out-Script_out;
2024-11-20 20:27:50 +08:00
tiledlayout(2,1)
ax1 = nexttile;
2024-10-08 17:58:26 +08:00
plot(n,iir_out,n,Script_out)
xlabel('n')
legend(leg1,leg2)
xlim(a)
title('time domain')
grid on
2024-11-20 20:27:50 +08:00
ax2 = nexttile;
2024-10-08 17:58:26 +08:00
plot(n,diff)
xlabel('n')
title('diff')
grid on
hold on
xlim(a)
2024-11-20 20:27:50 +08:00
linkaxes([ax1,ax2],'x');
2024-11-26 20:59:57 +08:00
[~,R_mpos_max] = max(diff);
[~,R_mpos_min] = min(diff);
plot(n(R_mpos_max),diff(R_mpos_max),'r*')
plot(n(R_mpos_min),diff(R_mpos_min),'r*')
text(n(R_mpos_max), diff(R_mpos_max), ['(',num2str(n(R_mpos_max)),',',num2str(diff(R_mpos_max)),')'],'color','k');
text(n(R_mpos_min), diff(R_mpos_min), ['(',num2str(n(R_mpos_min)),',',num2str(diff(R_mpos_min)),')'],'color','k');