ROBOT_DEM.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. function E = ROBOT_DEM
  2. % Tests routines in DEM GUI
  3. %__________________________________________________________________________
  4. % close and clear everything
  5. %--------------------------------------------------------------------------
  6. try
  7. cd(fullfile(spm('Dir'),'toolbox','DEM'))
  8. catch
  9. cd('C:\spm\toolbox\DEM');
  10. end
  11. close all force
  12. if exist('DEMO.ps','file')
  13. delete('DEMO.ps')
  14. end
  15. clc
  16. % get scripts and functions
  17. %--------------------------------------------------------------------------
  18. P = importdata('DEM_demo.m');
  19. R = {};
  20. E = {};
  21. for i = 1:length(P)
  22. k = strfind(P{i},'handles,');
  23. if ~isempty(k)
  24. str = P{i}(k + 10:end - 2);
  25. if exist(str,'file') == 2
  26. R{end + 1,1} = str;
  27. end
  28. end
  29. end
  30. % execute scripts and functions
  31. %--------------------------------------------------------------------------
  32. N = length(R);
  33. T = zeros(1,N);
  34. for i = 1:N
  35. try
  36. % run routine
  37. %------------------------------------------------------------------
  38. fprintf('\nChecking %s\n',R{i})
  39. t = tic; eval(R{i}); T(i) = toc(t);
  40. % print graphics
  41. %------------------------------------------------------------------
  42. H = sort(get(0,'Children'));
  43. for j = 1:length(H);
  44. figure(H(j))
  45. axes('position',[.05 .98 .9 .02]);
  46. str = [get(gcf,'Name') ': ' R{i}];
  47. text(0,0.5,str,'Fontsize',10,'Fontweight','Bold')
  48. axis off
  49. spm_print('DEMO.ps',gcf);
  50. end
  51. delete(H)
  52. catch
  53. % errors
  54. %------------------------------------------------------------------
  55. E{end + 1} = lasterror;
  56. end
  57. fprintf('\n\n --------***-------- \n\n')
  58. end
  59. % Show failed routines
  60. %--------------------------------------------------------------------------
  61. for i = 1:length(E)
  62. disp(E{i}.message)
  63. disp(E{i}.stack(end - 1))
  64. disp('------------------------------------------------')
  65. end