Borrar filtros
Borrar filtros

Creating for loop for matrixes?

1 visualización (últimos 30 días)
jack star
jack star el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016
Hi all. I am using these codes to calculate To and Fo. I have matrix x(150x160) and I need to process each column of it x(:,1),x(:,2),x(:,3),...,x(:,160) I think the problem is pks and locs have different matrix dimensions for each frames. How can I create for loop to find To and Fo?
For example codes for x(:,1) :
autocor=xcorr(x(:, 1));
[pks,locs] = findpeaks(autocor)
X=pks;
[a,z1] = max(X);
X(z1)= NaN;
[b,z2] = max(X);
To=(abs(locs(z1)-locs(z2)))/Fs;
Fo=1/To

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
Editada: Azzi Abdelmalek el 18 de Abr. de 2016
To=cell(1,10);
Fo=To;
for k=1:10
autocor=xcorr(x(:, 1));
[pks,locs] = findpeaks(autocor)
X=pks;
[a,z1] = max(X);
X(z1)= NaN;
[b,z2] = max(X);
To{k}=(abs(locs(z1)-locs(z2)))/Fs;
Fo{k}=1/To{k}
end

Más respuestas (0)

Categorías

Más información sobre Sparse Matrices 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