Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. function [train, t, fs] = hb_clickTrain( frq, dura, width, fs, plotOption )
  2. %
  3. % Ex-> [train]=hb_clickTrain(40, 1.0, 0.001, 10000, true);
  4. % (1) frq: stimulus frequency (unit: Hz)
  5. % (2) dura: stimulus duration (unit: sec)
  6. % (3) width: pulse width (unit: sec)
  7. % (4) fs: sampling frequency (unit: Hz)
  8. % (5) plotOption: plot or not (true/false)
  9. % Written by Hio-Been Han, Jeelab, KIST, hiobeen@yonsei.ac.kr, 20170415
  10.  
  11. if nargin < 5
  12. plotOption = 0; end
  13.  
  14. total_length = dura * fs;
  15. train = zeros( [total_length, 1] );
  16.  
  17. lencycle = fs*(1/frq);
  18. onIdx = 1:lencycle:total_length;
  19. temp_outL = train ;
  20. for ind = onIdx
  21. temp_outL(ind:ind+(width*fs)) = 1;
  22. end
  23.  
  24. train = temp_outL(1:total_length);
  25. train(end)=0;
  26.  
  27. t = [1:length(train)]/fs;
  28.  
  29. if plotOption
  30. % figure;
  31. plot(t*1000, train, 'ko-');
  32. xlabel('Time (msec)'); ylabel('v'); axis tight;
  33. axiss=axis;
  34. axis([axiss(1)-100 axiss(2)+100 axiss(3)-.1 axiss(4)+.1]);
  35. end
  36.  
  37. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement