load_scope.m 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function load_scope(files,refresh_rate,sample_frequency)
  2. close all
  3. shot_size=round(sample_frequency/refresh_rate);
  4. ring=zeros(shot_size*20,1)';
  5. fig = figure('Position',[500,500,800,600],...
  6. 'NumberTitle','off',...
  7. 'Name','Scope',...
  8. 'doublebuffer','on',...
  9. 'HandleVisibility','on',...
  10. 'Renderer', 'openGL');
  11. plot_ref=plot(zeros(10,1));
  12. for i=1:length(files)
  13. %files{i};
  14. fid=fopen(files{i},'r');
  15. fseek(fid,0,1);
  16. e_o_f=ftell(fid);
  17. fseek(fid,0,-1);
  18. while (ftell(fid)<e_o_f)
  19. tic
  20. [data,c]=fread(fid,shot_size,'short');
  21. data=(data/10000)';
  22. %data=rand(1,length(data));
  23. ring=[ring data];
  24. ring(1:length(data))=[];
  25. start_display(ring,plot_ref);
  26. stop_time=toc;
  27. while stop_time<(1/refresh_rate)
  28. stop_time=toc;
  29. end
  30. end
  31. fclose(fid)
  32. end