Median power using find function
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Chris
2021년 10월 24일
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!