Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

RealSpec.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. % Author and Date: Ehsan Azar 14 Sept 2009
  2. % Copyright: Blackrock Microsystems
  3. % Workfile: RealSpec.m
  4. % Purpose: Realtime spectrum display. All sampled channels are displayed.
  5. close all;
  6. clear variables;
  7. f_disp = 0:0.1:15; % the range of frequency to show spectrum over.
  8. % Use f_disp = [] if you want the entire spectrum
  9. collect_time = 0.1; % collect samples for this time
  10. display_period = 0.5; % display spectrum every this amount of time
  11. cbmex('open'); % open library
  12. proc_fig = figure; % main display
  13. set(proc_fig, 'Name', 'Close this figure to stop');
  14. xlabel('frequency (Hz)');
  15. ylabel('magnitude (dB)');
  16. cbmex('trialconfig', 1); % empty the buffer
  17. t_disp0 = tic; % display time
  18. t_col0 = tic; % collection time
  19. bCollect = true; % do we need to collect
  20. % while the figure is open
  21. while (ishandle(proc_fig))
  22. if (bCollect)
  23. et_col = toc(t_col0); % elapsed time of collection
  24. if (et_col >= collect_time)
  25. [spike_data, t_buf1, continuous_data] = cbmex('trialdata',1); % read some data
  26. nGraphs = size(continuous_data,1); % number of graphs
  27. % if the figure is still open
  28. if (ishandle(proc_fig))
  29. % graph all
  30. for ii=1:nGraphs
  31. % get frquency of sampling
  32. fs0 = continuous_data{ii,2};
  33. % get the ii'th channel data
  34. data = continuous_data{ii,3};
  35. % number of samples to run through fft
  36. collect_size = min(size(data), collect_time * fs0);
  37. x = data(1:collect_size);
  38. if isempty(f_disp)
  39. [psd, f] = periodogram(double(x),[],'onesided',512,fs0);
  40. else
  41. [psd, f] = periodogram(double(x),[],f_disp,fs0);
  42. end
  43. subplot(nGraphs,1,ii,'Parent',proc_fig);
  44. plot(f, 10*log10(psd), 'b');title(sprintf('fs = %d t = %f', fs0, t_buf1));
  45. xlabel('frequency (Hz)');ylabel('magnitude (dB)');
  46. end
  47. drawnow;
  48. end
  49. bCollect = false;
  50. end
  51. end
  52. et_disp = toc(t_disp0); % elapsed time since last display
  53. if (et_disp >= display_period)
  54. t_col0 = tic; % collection time
  55. t_disp0 = tic; % restart the period
  56. bCollect = true; % start collection
  57. end
  58. end
  59. cbmex('close'); % always close