Median power using find function

11 visualizaciones (últimos 30 días)
Claudia Vondra
Claudia Vondra el 23 de Oct. de 2021
Respondida: Chris el 24 de Oct. de 2021
Hi, I need to break 60000 data points into 60-1000 array intervals and covert to the frequency domain. From there I need to find the median power frequency for each interval but I keep getting array size errors for each change. Below is the code. Any help would be great!
[signal]=RMS(p31(:,2),20);
fixsignal=signal(6153:66153);
t=1:60;
for k=1:60
for i=1:length(fixsignal(:,1))
A=fft(fixsignal(i:i+999)); % Do FFT on the signal data.
for j=1:length(A)
A(1)=[];
n=round(length(A/2));
power=abs(A(1:n)).^2;
nyquist=1/2;
freq=(1:n)/(n)*nyquist*1000;
integ=cumtrapz(power);
ninteg=integ/max(integ);
power_med(1,k)=find(ninteg(1,j:)>=0.5,1); %Error statement is always on this line
end
end
%power_med(:,k)=median(split(:,k));
end

Respuestas (1)

Chris
Chris el 24 de Oct. de 2021
From that line,
ninteg(1,j:)
is invalid syntax. If you want element j through the end of the vector, you need
ninteg(1,j:end)
Also, if everything in your code consists of vectors (as opposed to two-dimensional arrays), you don't necessarily need that "1" in your indexing.
ninteg(j:end)
would be sufficient. Similarly, if fixsignal is a column vector,
fixsignal
is equivalent to
fixsignal(:,1)
and
fixsignal(:)
All variations select all elements of the first column of fixsignal, or in other words the entire signal.
If you pay attention to the size of the variables in Matlab's Workspace panel, it might help you understand future array size error messages (though probably not in this case, if I have correctly pointed out the problem)

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by