cell matrix: code does not work.. can somebody help?

i got a load of data and wanted to seperate it and store it into a cell array
frames = [680, 4280, 4940, 8380, 9140, 12460, 13220, 16980, 17780, 21400;
860, 4100, 4420, 7700, 8340, 11760, 12420, 15760, 16740 ,20060;
1180, 4240, 4980, 8020, 8520, 11780, 12660, 16140, 17040, 20020;
980, 4100, 4820, 7940, 8640, 11920, 12780, 15880, 16840, 20160];
zyklen = cell(length(frames(1,:))/2,length(frames(:,1)),2); %5...WH, 4...Sätze, 2...vm/s
for i = 1:length(zyklen(:,1,1))
for l = 1:2
for j = 1:length(zyklen(1,:,1))
for k = 1:2
if(j<length(zyklen(1,1,:))-1)
zyklen{i,j,k} = num2cell(a(frames(l,j):frames(l,j+1), k));
zyklen{i,j,k} = num2cell(b(frames(l+2,j):frames(l,j+1), k));
zyklen{i,j,k} = num2cell(c(frames(l+4,j):frames(l,j+1), k));
zyklen{i,j,k} = num2cell(d(frames(l+6,j):frames(l,j+1), k));
else
zyklen{i,j,k} = num2cell(a(frames(l,j):frames(l,j), k));
zyklen{i,j,k} = num2cell(b(frames(l,j):frames(l,j), k));
zyklen{i,j,k} = num2cell(c(frames(l,j):frames(l,j), k));
zyklen{i,j,k} = num2cell(d(frames(l,j):frames(l,j), k));
end
end
end
end
end
in frames are the beginning and endvalues of a EMG, i just want to store them in cells to get them compact in one place. but it seems not to work, as if my matrices (a,b,c,d) are about 22000x2 and every cell only gets 1 value.
cellplot(zyklen(1,1,1));
there should be some thousand values

Respuestas (1)

Jan
Jan el 12 de Mzo. de 2018
Editada: Jan el 12 de Mzo. de 2018
Try to replace
zyklen{i,j,k} = num2cell(a(frames(l,j):frames(l,j+1), k));
by
zyklen{i,j,k} = a(frames(l,j):frames(l,j+1), k);
This is a bad idea:
if(j<length(zyklen(1,1,:))-1)
Prefer:
if j < size(zyklen, 3) - 1
because it does not waste time with creating zyklen(1,1,:) only to measure its length.

La pregunta está cerrada.

Preguntada:

el 10 de Mzo. de 2018

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by