Reverberation Time

trying to design a T60 measurement function. I think i've worked it out but every time i run the function it crashes Matlab. I must have an infinite loop or using a very inefficient way of calculating the t60 but i can't see why it's not working. Any help would be much appreciated thank you
function [ T60Plot ] = T60Plot(input,Fs)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
modInput=sqrt(input.^2);
L=length(input);
maxA = cumsum(modInput);
invertModInput = modInput';
for n = 1:L; n1 = 0;
if 20*log10(sum(modInput(n:L))./maxA)<=-60;
n1 = n1;
else
n1 = n1+1;
end
end
T60Plot = n1/Fs;
end

댓글 수: 1

Walter Roberson
Walter Roberson 2012년 5월 11일
Do not use the same output variable name as your function name.

댓글을 달려면 로그인하십시오.

답변 (2개)

Daniel Shub
Daniel Shub 2012년 5월 11일

0 개 추천

There are already a three implementations FEX: t60

댓글 수: 1

Sam
Sam 2012년 5월 11일
Yes there are but i've already tried one to understand it and it didn't work. One is far too complicated for me to understand. I'm also supposed to write the code myself. I would rather like to use the original stuff above.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2012년 5월 11일

0 개 추천

You set n1 to 0 each iteration through the "for" loop. The "n1" after the iteration of a loop is thus always going to be 0 or 1. Then you go on to the next iteration, overwriting n1. The result would be the same as if your "for" went from L:L instead of 1:L .

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

Sam
2012년 5월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by