37 lines
869 B
Matlab
Executable File
37 lines
869 B
Matlab
Executable File
function result = diff_plot(iir_out, Script_out,leg1,leg2,a)
|
|
|
|
N = min(length(iir_out),length(Script_out));
|
|
iir_out = iir_out(1:N);
|
|
Script_out = Script_out(1:N);
|
|
n = 0:1:N-1;
|
|
diff = iir_out-Script_out;
|
|
|
|
tiledlayout(2,1)
|
|
ax1 = nexttile;
|
|
plot(n,iir_out,n,Script_out)
|
|
xlabel('n')
|
|
legend(leg1,leg2)
|
|
xlim(a)
|
|
title('time domain')
|
|
grid on
|
|
|
|
ax2 = nexttile;
|
|
plot(n,diff)
|
|
xlabel('n')
|
|
title('diff')
|
|
grid on
|
|
hold on
|
|
xlim(a)
|
|
linkaxes([ax1,ax2],'x');
|
|
|
|
[~,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');
|
|
|
|
result = max(abs(diff(R_mpos_max)),abs(diff(R_mpos_min)));
|