Robust edge/flank detection - HELP!!

46 次查看(过去 30 天)
youjarr
youjarr 2019-1-26
Hey guys,
i have an measurement and read in three rect. signals.
I need to detect the pos. and neg. edges/flanks of the three signals.
Sometimes I have the problem that my code doesnt detect all flanks/edges and i dont know why.
In the attachment u find a pictures with with all three signals and the detected signals but not all are right.
I counted them by hand:
left Signal -> 28 pos. and 27 neg.
middle Signal -> 27 pos and 27 neg (this signal is ok)
right signal -> 27 pos and 27 neg
So if u compare it only the middle one is correct.
My Code for that detection is:
posFlankHall_1 = find(diff(V_Hall_1)>1.6)+1;
negFlankHall_1 = find(diff(V_Hall_1)<-1)+1;
posFlankHall_1OrigLength = length(posFlankHall_1);
negFlankHall_1OrigLength = length(negFlankHall_1);
posFlankHall_2 = find(diff(V_Hall_2)>1.6)+1;
negFlankHall_2 = find(diff(V_Hall_2)<-1)+1;
posFlankHall_2OrigLength = length(posFlankHall_2);
negFlankHall_2OrigLength = length(negFlankHall_2);
posFlankHall_3 = find(diff(V_Hall_3)>1.6)+1;
negFlankHall_3 = find(diff(V_Hall_3)<-1)+1;
posFlankHall_3OrigLength = length(posFlankHall_3);
negFlankHall_3OrigLength = length(negFlankHall_3);
I have three question to that:
1) Is there maby a easier and more robust way to detect the flanks/edges?
2) How can I automatically find out the values (like in this case 1.6 and -1) so i can use it on every signal i read in
3) If there is no easier way is there a way to improve this one?
Thank you very much in advance.

回答(1 个)

Star Strider
Star Strider 2019-1-27
See if the midcross (link) function will do what you want.
I would have suggested this earlier, however even though it has been part of the Signal Processing Toolbox since R2012a, I just now discovered it.
  2 个评论
youjarr
youjarr 2019-1-28
Hey Star Strider,
i cannot use this command.
i get this error:
Error using midcross (line 65)
Expected X to be one of these types:
double
Instead its type was single.
Star Strider
Star Strider 2019-1-28
That is not mentioned in the documentation.
Try this:
C = midcross(double(X))
If you pass any other arguments to it, double() them as well.
Also, note the related functions at the end of that documentation page.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by