introduce new values into an array and shift the others
14 views (last 30 days)
Show older comments
Hello,
i have a 256x2840 matrix, this matrix contain values of an eeg signal almost periodic and each coloumn (256 samples) contain each period.
I should introduce random values (for ex. 9 samples) with mean zero and standard deviation of 1,2 or 10ms at the beginning of the signal, so that all the other value are shifted and the periods of the signal are no more in phase..
I turned the matrix in the vector ev and i did:
x=randn(9,1);
for i=1:9
ev(1:9)=x(i)';
end
but i guess that in this way the code changes just the first 9 values and the other doesn't shift...help me please!!!! Tks!!
0 Comments
Accepted Answer
Jan
on 4 Dec 2011
Do you want to insert the same random signal at the start of each channel?
Signal = rand(256, 2840);
x = randn(1, 9) * 1.2;
Signal = [repmat(x, 256, 1), Signal];
Or a random signal, which is different for each channel?
Signal = [randn(256, 9) * 1.2, Signal];
[EDITED] Another approach:
x = rand(256, 2840); % Original signal
lenX = size(x, 2);
for i = 1:256
lenInsert = floor(rand * 10);
xInsert = randn(1, lenInsert);
x(i, :) = cat(2, xInsert, x(i, 1:lenX - lenInsert));
end
3 Comments
Jan
on 4 Dec 2011
I'm still confused about the "2 or 10ms".
How is the length of the signal to be inserted defined?
See [EDITED] in my answer above.
More Answers (0)
See Also
Categories
Find more on Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!