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-10-08 17:58:26 +08:00
|
|
|
[diff_max,R_mpos] = max(abs(diff));
|
|
|
|
plot(n(R_mpos),diff(R_mpos),'r*')
|
|
|
|
text(n(R_mpos), diff(R_mpos), ['(',num2str(n(R_mpos)),',',num2str(diff(R_mpos)),')'],'color','k');
|
|
|
|
% max(abs(diff))
|