Clear Filters
Clear Filters

To catch correct jump and store the number

2 views (last 30 days)
suman Dhamala
suman Dhamala on 20 Feb 2018
Edited: suman Dhamala on 21 Feb 2018
Hi I want to record the up and down count of the signal when it satisfies my threshold condition but the code is not working. I need to catch the jumps shown by red in the image. I have attached the image as well as my code so can anyone solve it sooner. Thank you for your help!
phi(1)=0.66702; phi(2)= 0.667003; phidc(1)=0;phidc(2)= 0.00001;
for n=2:10^5 ;
p= 0.5.*rand-0.25; q = 1.*rand -0.5 ;
phi(n+1)= 0.0031+ 1.9676*phi(n) -0.9686*phi(n-1)- 0.0039*cos( 0.5*phidc(n))* sin(phi(n)) + 0.0390* q ;
phidc(n+1)= 1.8873*phidc(n) -0.9686*phidc(n-1)- 0.0079*sin(0.5*phidc(n))* cos(phi(n)) + 4*0.0390* p ;
if phi(n+1)> 4.5 && phi(n)< 4.5 ;
count1= count1+1 ;
UP(count1)= n;
if phi(n+1)< 1.5 && phi(n)> 1.5 ;
count0= count0+1 ;
DOWN(count0)= n;
end
end
end
  4 Comments
Star Strider
Star Strider on 20 Feb 2018
You will likely have to do that in hardware, for example with a Schmitt trigger (link).
It might be possible to do that in real-time. I have no real-time Toolboxes, so I have no experience with that.
suman Dhamala
suman Dhamala on 20 Feb 2018
The code is very simple. I am not getting an idea to use two if loop in a correct way I guess

Sign in to comment.

Answers (0)

Categories

Find more on Physical Units in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!