0001 function diffPlot(vec1, vec2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin<1, selfdemo; return ;end
0013
0014 vec1=vec1(:);
0015 vec2=vec2(:);
0016 name1=inputname(1);
0017 name2=inputname(2);
0018
0019 subplot(2,1,1);
0020 plot(1:length(vec1), vec1, '-', 1:length(vec2), vec2, '-');
0021 grid on
0022 title(sprintf('Curves of %s and %s\n', name1, name2));
0023 legend(name1, name2);
0024 subplot(2,1,2);
0025 minLen=min(length(vec1), length(vec2));
0026 plot(1:minLen, abs(vec1(1:minLen)-vec2(1:minLen)), '-');
0027 maxAbsDiff=max(abs(vec1(1:minLen)-vec2(1:minLen)));
0028 grid on
0029 title(sprintf('Abs. diff. of %s and %s, with maxAbsDiff=%g\n', name1, name2, maxAbsDiff));
0030
0031
0032 function selfdemo
0033 x = randperm(10);
0034 y = x.^(1/1000000000).^1000000000;
0035 diffPlot(x, y);