How to save data at each iteration in a cell array?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Joana
el 17 de Abr. de 2020
Comentada: Rik
el 17 de Abr. de 2020
Hi,
I have saved data sests where i have two variables of 3-D, A and B. I want to load it for each subject and save it in a cell array, as the variables have the same name for each subject. But the size is varied across each subject.
How can i do that.?
I am doing following:
for subject= 1:2
resultFileName = sprintf('Sub0%i_Epochs.mat',subject); % generate result filename
load(resultFileName)
A_Epochs{:,:,:}= epochs([1: size(epochs,1)/2],6,:);
B_Epochs{:,:,:}= epochs([size(epochs,1)/2+1:end],6,:);
end
3 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Abr. de 2020
A_Epochs{subject}= epochs([1: size(epochs,1)/2],6,:);
B_Epochs{subject}= epochs([size(epochs,1)/2+1:end],6,:);
3 comentarios
Walter Roberson
el 17 de Abr. de 2020
Editada: Walter Roberson
el 17 de Abr. de 2020
N_subjects=2;
A_Epochs=cell(1,N_subjects);
B_Epochs=cell(1,N_subjects);
for subject= 1:N_subjects
resultFileName = sprintf('Sub0%i_Epochs.mat',subject); % generate result filename
S=load(resultFileName);
A_Epochs{subject} = S.epochs(1:end/2,6,:);
B_Epochs{subject} = S.epochs(end/2+1:end,6,:);
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!