Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Pick a value at a decided moment

Subject: Pick a value at a decided moment

From: Matt

Date: 28 Jun, 2012 07:53:07

Message: 1 of 4

Hello !

I am facing a problem. I have a signal which is a sin wave but which doesn't go to negative values (it is flat at 0 when it should go negative). I have to detect the moment when it reaches 0 (easy) and then get the value of another block at that exact moment.

But I don't want to get continuous value. I mean if I use a switch to detect when it reaches 0, it will be "true" for some time, while I want only to get 1 single value.

I don't know if this is clear enough but thanks in advance for the help !

Matt :-)

Subject: Pick a value at a decided moment

From: Lothar Schmidt

Date: 28 Jun, 2012 07:59:32

Message: 2 of 4

Am 28.06.2012 09:53, schrieb Matt:
> Hello !
>
> I am facing a problem. I have a signal which is a sin wave but which
> doesn't go to negative values (it is flat at 0 when it should go
> negative). I have to detect the moment when it reaches 0 (easy) and then
> get the value of another block at that exact moment.
>
> But I don't want to get continuous value. I mean if I use a switch to
> detect when it reaches 0, it will be "true" for some time, while I want
> only to get 1 single value.
>
> I don't know if this is clear enough but thanks in advance for the help !
>
> Matt :-)

you are interested in moments which cover two conditions:

- sine curve in the moment before > 0
AND
- sine curve in the current moment = 0

aren't you?

Lothar

Subject: Pick a value at a decided moment

From: Matt

Date: 28 Jun, 2012 08:10:07

Message: 3 of 4

I have to detect when the sin curve is equal to 0. But not during the whole moment when it is equal to 0 : only when it gets to 0 for the first time.

Then I have to read the value of another block at that exact time and get the value of this block.

:-)

Subject: Pick a value at a decided moment

From: Lothar Schmidt

Date: 28 Jun, 2012 14:45:44

Message: 4 of 4

Am 28.06.2012 10:10, schrieb Matt:
> I have to detect when the sin curve is equal to 0. But not during the
> whole moment when it is equal to 0 : only when it gets to 0 for the
> first time.
>
> Then I have to read the value of another block at that exact time and
> get the value of this block.
>
> :-)

maybe i repeat myself:

the moment you are interested in must fit two conditions:

(A) y_sin(t)=0
AND
(B) y_sin(t-1)>0

once found a moment t fitting these conditions you can take y_other(t).

If you need more help show your code.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us