Random allocation of variables

1 回表示 (過去 30 日間)
MiauMiau
MiauMiau 2016 年 11 月 16 日
コメント済み: MiauMiau 2016 年 11 月 16 日
Hi
I have two Signals, say Sig1 and Sig2 - both sine waves with different amplitudes. Now I have two other variables, RHand and LHand, standing for the right respectively left hand. What I want to do is to randomly allocate the signals at the start of an experiment to one of the two hands - how is that done fastest?
I can think of something like:
randper = randperm(2);
Sig = [Sig1,Sig2];
LHand = [];
LHand = Sig(randper(1));
RHand = Sig(randper(2));
..but that seems somehow overly complicated..?
  2 件のコメント
KSSV
KSSV 2016 年 11 月 16 日
randper will be 1X2, then your LHand and RHand will be 1x1 each. Is that you want?
MiauMiau
MiauMiau 2016 年 11 月 16 日
I want to randomly allocate at the start of my code Sig1 and Sig2 either to the left or to the right hand..not sure what you mean

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

採用された回答

Jan
Jan 2016 年 11 月 16 日
if rand < 0.5
LHand = Sig1;
RHand = Sig2;
else
LHand = Sig2;
RHand = Sig1;
end

その他の回答 (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