Using the 'diff' function inside the 'find' function.
4 次查看(过去 30 天)
显示 更早的评论
Greetings,
So I am trying to identify from a wav file each time a new note is struck. looking at the 2nd derivative of it when there is a rapid change in magnitude i assume a new note is played. Now i need to write a function that says something like:
for k = 1:1:length(d2x);
if diff(d2x(k,1) and d2x((k+1),1)) > 'some-value'
store it.
end.
so it cycles through the matrix and references everytime the difference between two neighbours is bigger than a value i will decide on.
Could somebody help me actually code this idea, my matlab is getting better but im at a real loss with this.
0 个评论
采纳的回答
更多回答(1 个)
Carlos
2013-3-12
Her is my guess. Why don´t you just store k in a vector? I mean something like
aux= zeros(length(d2x));
aux2=1;
for k = 1:1:length(d2x)
if diff(d2x(k,1) and d2x((k+1),1)) > 'some-value'
aux(aux2)=k;
aux2=aux2+1;
end
end
By doing this, in your vector aux you would have the indices of the positions where you detect the change.
2 个评论
Carlos
2013-3-12
So you want to compare d2x(k,1) and d2x((k+1),1)? If I am undersatnding well,just do:
if (d2x(k,1)-d2x((k+1),1))> 'some-value'
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!