saving a value and reseting other variables in a loop
이전 댓글 표시
I have the following situation:
for d=1:numel(Time_delay) % time delay is a (8x1000) matrix
if rem(d,8)==0;
mic_out(1,:)=mic_in(1,:);
out= sum(sum(mic_out,1).^2,2) ; %computing the energies
mic_out=zeros(size(mic_out));
end
mic_out(rem(d,8)+1,:)=del(mic_in(rem(d,8)+1,:),Time_delay(d+1));
end
Here, 'del' is a function which delays the 8 signals in 'mic_in(8x10000)' according to delays specified in Time_delay'
The first row in Time_delay is all zeros that is, no delay applied to signals in 'mic_in'. Hence, I replace it with 1st row of signal that is, with mic_in(1,10000). Each time I change column in Time_delay (jump from column 1 to column 2 and so on), I need to add the 8 delayed signals in mic_out row-wise,square the elements in the row hence obtained and add the result colum-wise (i.e. calculate energy) and store only the energy values in a variable 'out', reset everything to zero and move on for the next set of 8 signals (that is next column in matrix 'Time_delay').
This process is repeated each time I jump from 1 colum to another of 'Time_delay', till I reach the last column. At the end I should be only left with the matrix 'out' containing the energies (for plotting and further analysis). I have problem in indexing the above variables according to my requirement.
Whats the most efficient way to achive this?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!