introduce new values into an array and shift the others
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Jan
2011-12-4
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 个评论
Jan
2011-12-4
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!