introduce new values into an array and shift the others

5 visualizzazioni (ultimi 30 giorni)
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!!

Risposta accettata

Jan
Jan il 4 Dic 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 Commenti
Jan
Jan il 4 Dic 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.
Sara
Sara il 5 Dic 2011
What have you written in [EDITED] solve my problem, thank you very much! But i don't understand if xInsert changes its length depending on the index i, that is if lenInsert changes with i, or it's a fixed value. Because i would need a vector of random values whose length (1-9 samples is ok) is variable and changes, randomly, with i (for ex. for 1=1, lenInsert=5; for i=2, lenInsert=9; ...)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Signal Processing in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by