Borrar filtros
Borrar filtros

How can I do a loop to extract vectors from a matrix?

2 visualizaciones (últimos 30 días)
Laura Mansilla Valle
Laura Mansilla Valle el 19 de Dic. de 2017
Comentada: Laura Mansilla Valle el 5 de En. de 2018
Hello, I am working with EEG signals and I have a 21*2560 matrix. I want to split it into 21 channels each one with nc*2500 taking into account that nc takes values from 1 to 21. Also store every channel in a new variable.
matriz= AD1; %AD1(21*2560)
[i,j]=size(matrix); for h=1:i c=M(h,:); % I want to create new vectors each time, if I do this only the last one is stored end

Respuestas (1)

Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy el 28 de Dic. de 2017
Editada: Ramnarayan Krishnamurthy el 28 de Dic. de 2017
The reason only the last one is stored at the end of the for loop is that 'c' is being overwritten each time the loop iterates.
Consider storing the new vectors created inside the for loop in a cell array. For example:
for h=1:i
c{h} = a(h,:)
end
c{1}, c{2} ...c{21} each contain a 1 x 2560 matrix.

Categorías

Más información sobre EEG/MEG/ECoG en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by