How to create a click-train with

DSFA

10 Comments

John D'Errico
John D'Errico on 22 Jul 2017
Edited: John D'Errico on 22 Jul 2017
So what is your question? Is this just a doit4me? Note that MATLAB is a computational tool, it is not designed for exact millisecond interfaces. You may need to consider a different tool for this purpose, depending on your requirements.
I'm looking for guidance on how to start. I'm a newbie but I've done the Matlab online tutorials. There is no help for click sounds or clicktrains, only for mouse clicks. I've created an array of zeros in which to put the ones to make the click but I'm a little lost when it comes to timing. I know the timing of my click intervals (75 ms to next click) and my clicks (100 microseconds) - see previous for other timing items. I know my sampling frequency is 32e3. I know my rate is 13.3 Hz. I'm missing how these all interact - how long would it run based on my sampling rate and frequency or do I set a time? We use Matlab all the time and it works beautifully for this. We combine it with Labview precision so it's not a problem. It would be nice if Matlab actually had help for the little things, like this. I can program more complicated things but I have trouble with this.
John, you didn't even attempt to answer the questions. This kind of support is nonsense. If you cannot provide support perhaps you should only answer questions from those people that don't require help.
@Patricia: As John I have to ask: What is your question?
I do not understand your message. What is a "click-train"? What is the meaning of "1s presented as 1 then two 1s then three 1s"? What is a SOA here? I do not get an idea of what you are talking of.
The SOA stays the same at 75 ms no matter if there is one,
two, or three ones.
This sounds like you have done something already. Then please post the code. Or is it a Simulink model? Then explain, which problem you want to solve. Take into account that most of the readers will not work exactly in your field.
Dear Jan: a click-train is can be created using a series of 1s in Matlab. You create a click by turning a 1 on and off. These are the parameters I used to create the click.
ici = 4; %inter-click interval for 2 or more clicks in ms. The clicks with intervening 0s are presented as 1, 75 ms, 1-4ms-1, 75ms, 1-4ms-1-4ms-1, 75ms, 1, etc.
Fs = 32e3; % sampling frequency
soa = 75; %time between click groups
dur = 1000; %ms in 1 second
rate = (dur/soa); %frequency of the impulse in Hz is 13.3
clicklength = ((Fs/dur)/Fs); %click length is equal to 100 microseconds (i.e. 0.001 ms)
num_samples = (Fs/rate); %number of samples = 2400
n_clicks = (1:3); %total number of clicktrain starts(ones) is Fs/soa = 426.6667 over entire Fs range
ti = 1/Fs:1/Fs:(dur/1000); % time index
Phase = 0
The creation of a click-train is a very popular question on this site and others as well. I have created a code that works but I think it's very messy. I think it could be done much cleaner.
SOA means Stimulus Onset Asynchrony.
@Patricia: I know a series of 1s as a "vector". E.g.:
v = [1,1,1,1]
I do not understand what "turning a 1 on and off" means. A number does not have a feature like "on" and "off".
I do not understand, what your code should do or what the comments mean,. E.g.:
clicklength = ((Fs/dur)/Fs); %click length is equal to 100 microseconds (i.e. 0.001 ms)
Why not simplifying it to
clicklength = 1/dur;
By the way, "100 microseconds" are not "0.001 ms".
Maybe the topic is very popular in this forum, but I did not heared of it yet. Again: What is your question? How can we help you? If you have a messy code and ask for improvements, post your code.
Your code looks okay. I'd omit the useless "clear,clc" and use fullfile instead of concatenating file names by [pth 'clicktrains_' ici_str '_' soa_str '_Fs32e3.xls'], but these are more cosmetic modifications. I do not see a potential for substantial improvements.
@Patricia: I've posted my comment as answer now. If it really helps you already, you can accept it. If you've found better details by your own, you can post them also and accept your own answer.
Original question from Google Cache:
"How to create a click-train with"
I need to create a click-train of 1s presented as 1 then two 1s then three 1s. The SOA is 75 ms. Each 1 is 100 microseconds and the interclick interval when there are two or three 1s is 4 ms. The SOA stays the same at 75 ms no matter if there is one,two, or three ones. It seems it should be quite easy.

Sign in to comment.

 Accepted Answer

Jan
Jan on 15 Jun 2018
Your code looks okay. I'd omit the useless "clear,clc" and use fullfile instead of concatenating file names by [pth 'clicktrains_' ici_str '_' soa_str '_Fs32e3.xls'], but these are more cosmetic modifications. I do not see a potential for substantial improvements.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 22 Jul 2017

Commented:

on 26 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!