pl2.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. % Copyright David Rowe 2009
  2. % This program is distributed under the terms of the GNU General Public License
  3. % Version 2
  4. function pl2(samname1, samname2, start_sam, end_sam, pngname)
  5. fs1=fopen(samname1,"rb");
  6. s1=fread(fs1,Inf,"short");
  7. fs2=fopen(samname2,"rb");
  8. s2=fread(fs2,Inf,"short");
  9. st = 1;
  10. en = length(s1);
  11. if (nargin >= 3)
  12. st = start_sam;
  13. endif
  14. if (nargin >= 4)
  15. en = end_sam;
  16. endif
  17. figure(1);
  18. clf;
  19. subplot(211);
  20. l1 = strcat("r;",samname1,";");
  21. plot(s1(st:en), l1);
  22. axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
  23. subplot(212);
  24. l2 = strcat("r;",samname2,";");
  25. plot(s2(st:en),l2);
  26. axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
  27. if (nargin == 5)
  28. % small image
  29. __gnuplot_set__ terminal png size 420,300
  30. s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
  31. eval(s)
  32. replot;
  33. % larger image
  34. __gnuplot_set__ terminal png size 800,600
  35. s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
  36. eval(s)
  37. replot;
  38. endif
  39. endfunction