I want the code to randomize the rows and present each row for 10 times

2 ビュー (過去 30 日間)
Bhagya Lakshmi Marella
Bhagya Lakshmi Marella 2019 年 8 月 24 日
編集済み: Walter Roberson 2019 年 8 月 24 日
I want the code to randomize the rows and present the stimulus by taking the each row values for 10 times. Here is the code that I have written.
Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0];
trial = 10;
for i = 1:trial;
for iter= 1:length(Decentration);
Decentration = Shuffle(Decentration, 2);
XDecentration = Decentration(:,1);
YDecentration = Decentration(:,2);
this presents the stimulus for 50 times but in a different proportion.
Please suggest a code for presenting each row of Decentation to be selected 10 times.
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 24 日
Can you explain more?
You have Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0]; data,
you expectation from the Decentration matrix data?

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 24 日
Decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0];
trial = 10;
n = size(Decentration, 1);
idx = repmat(1:n, 1, trial);
order = randperm(size(idx,2));
randrows = Decentration(order,:);
XDecentration = randrows(:,1);
YDecentration = randrows(:2);
This code will present each row exactly trial times, but not in groups. For example, the second row might happen to occur twice in the first 10 stimuli. Or occur 10 times even (though that is not likely)
This is not the code to present each stimuli exactly once per trial: it is code that preserves the correct portions of entries over the entire experiment but not in the short term.
  2 件のコメント
Bhagya Lakshmi Marella
Bhagya Lakshmi Marella 2019 年 8 月 24 日
編集済み: Bhagya Lakshmi Marella 2019 年 8 月 24 日
This code gives error.
Index exceeds matrix dimensions.
Error in Disp_InvGabor (line 77)
randrows = Decentration(order,:);
Walter Roberson
Walter Roberson 2019 年 8 月 24 日
編集済み: Walter Roberson 2019 年 8 月 24 日
randrows = Decentration(idx(order),:);

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

その他の回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 24 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 24 日
Is this?
decentration = [0, 0.5; 0, 0; 0, -0.5; -0.5,0; 0.5, 0];
random_data=decentration(randperm(size(decentration, 1)),:);
[rows colm]=size(random_data);
trial = 10;
decentration_data=cell(rows,trial);
for i=1:rows
for j=1:trial
decentration_data{i,j}=random_data(i,:);
% I assume you have some process here, like apply stimulus to respective rows
end
end
  5 件のコメント
Bhagya Lakshmi Marella
Bhagya Lakshmi Marella 2019 年 8 月 24 日
Thank you so much.
It works. But it presents the selected random_data 10 times continuously. I also want this to be random
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 24 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 24 日
trial=randi(10);
% This generages the random trial number (maximum 10), change it accordingly
Like
trial=randi(maximum_allowable_trail_number);
%....................^^ enter any max number here
Check here examples
>> trail=randi(20)
trail =
16
>> trail=randi(20)
trail =
7
>> trail=randi(20)
trail =
11
Good Wishes!

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


Bruno Luong
Bruno Luong 2019 年 8 月 24 日
編集済み: Bruno Luong 2019 年 8 月 24 日
The array B of the below has exactly 10 times each row of A in random order:
m = size(A,1);
B = A(mod(randperm(10*m),m)+1,:);

カテゴリ

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