Extracting values between certain range and storing it

1 回表示 (過去 30 日間)
TANMAYEE PATHRE
TANMAYEE PATHRE 2019 年 6 月 27 日
コメント済み: Guillaume 2019 年 6 月 28 日
I have a 28X12 matrix of tempo values (bpm) recording from a tapping experiment. The rows represent number of stimuli (28) and columns represent number of test subjects (12). I want to have the most correct tempo for particular musical stimuli. But I am looking for a certain range of tempo values which I have taken as 10% which means if the first stimuli has the tempo 224 bpm. The lower limit will be 201 and upper limit is 246. I would then want to extract all the tempo values within the specified range for that particular stimuli.
tempo_drums_round = round(tempo_drums); %Rounding the values
tempoModedrums = mode(tempo_drums_round,2); %Most used value for tempo for drums
%To extract all the values between certain range
for t = 1:length(tempoModedrums)
t_low(t) = tempoModedrums(t)-tempoModedrums(t)/10;
t_low = t_low';
t_high(t) = tempoModedrums(t)+tempoModedrums(t)/10;
t_high = t_high';
t_range = [t_low t_high];
end
I am stuck after this!
  2 件のコメント
Guillaume
Guillaume 2019 年 6 月 27 日
Note that your loop isn't needed. It's simply:
tempo_drums_round = round(tempo_drums); %Rounding the values
tempoModedrums = mode(tempo_drums_round,2); %Most used value for tempo for drums
t_low = tempoModedrums - tempoModedrums / 10;
t_high = tempoModedrums + tempoModedrums / 10;
t_range = [t_low, t_high];
which could be coded even more simply as:
tempo_drums_round = round(tempo_drums); %Rounding the values
tempoModedrums = mode(tempo_drums_round,2); %Most used value for tempo for drums
t_range = tempoModedrums + tempoModedrums ./ [-10, 10]; %subtract (1st column) and add (2nd column) tempoModedrums / 10 to tempoModedrums
Considering that in each row, you may have a different number of subjects within your band, what do you want as output? It can be a matrix, it could be a cell array.
TANMAYEE PATHRE
TANMAYEE PATHRE 2019 年 6 月 27 日
Yes, there will be different number of subjects in each row. In the end, I want the number of people who agreed for a particular stimuli. Eg., The tempo mode is 224 bpm and t_range = [201 246]. And the values are:
249 227 227 224 111 325 219 224 224 328 148 113
Then, 6 people gave the most correct tempo for the first stimuli. The matrix will be 28x1.
I do not know how to proceed further.

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2019 年 6 月 27 日
Ah, well if you just want the number of people within the band then:
tempo_drums_round = round(tempo_drums); %Rounding the values
tempoModedrums = mode(tempo_drums_round,2); %Most used value for tempo for drums
t_low = tempoModedrums - tempoModedrums / 10;
t_high = tempoModedrums + tempoModedrums / 10;
countinrange = sum(tempo_drums >= t_low & tempo_druns <= t_high, 2)
  2 件のコメント
TANMAYEE PATHRE
TANMAYEE PATHRE 2019 年 6 月 28 日
Thank you so much! That worked :)
Guillaume
Guillaume 2019 年 6 月 28 日
Then accept the answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by