Hi all,
I have two signals meg1 and meg2: [3 x 1801 x 53] and [3 x 1801 x 60] type meeg. I can easily split them into three arrays of : 1 x 1801 x 53 type double. But what I need to do is to make both meg signals as random as possible so preferebly shuffle the elements between them two like n times. I tried to do it just within each matrix with function randswap http://www.mathworks.co.uk/matlabcentral/fileexchange/12621-randswap but it gives an error for elements type double. Has anyone got any idea how to do it? Would be veeeery grateful!!
Many thanks in advance, Lidia

 채택된 답변

Image Analyst
Image Analyst 2014년 7월 6일

0 개 추천

What do you mean "between them"? They're different sizes in the 3rd dimension.
Here, use randperm(). Try this:
m = magic(5) % Sample data
% Get random indexes to pull the new values from.
randomIndexes = randperm(numel(m));
% Assign random locations to new matrix
mNew = reshape(m(randomIndexes), size(m))

댓글 수: 2

Lidia
Lidia 2014년 7월 6일
Hi, They are different sizes but they don't need to exchange all the elements. Yeah it worked. Thank you so much! So m(randomIndexes) transforms 'm' to a vector?
Image Analyst
Image Analyst 2014년 7월 6일
Yes. That's "linear indexing" - it gives a 1D vector. So that's why I had to call reshape() - to get it back into the original shape.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2014년 7월 6일

댓글:

2014년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by