Switching sinusoidal signals at the same ampltude and in the same half wave
Show older comments
Hi!
I have the following problem in MATLAB/Simulink and I hope to get some support and/or ideas:
I need to switch at runtime between a sinusoidal signal and a distorted sinusoidal signal. The signals might have a phase shift as well as a slightly different frequency.
The external trigger signal accesses directly the real-time data forcing the signal sources in the simulink model to switch.
However, in order to be allowed to switch, the signals must have the same amplitude and both of them must be either in the positive or negative half wave.
Checking for the same amplitude is quite simple but how can I check the phasing? And if I know the phasing, how can I shift one of the signals so that they are in the same half wave and still have the same amplitude?
I appreciate any response
Kind regards
Answers (1)
Guy Rouleau
on 20 Jun 2011
0 votes
Doing exactly what you describe can be pretty complex. If you are constructing the signals in the model using basic blocks, it might be possible to play with the equations to determine when your conditions will happen. Or you can enable (in other words "start") the second signal in specific condition, that way you don't need to check both signals match, you check only the active one. This really depends on how you create these signals.
If the reason you are doing that is to obtain a smooth transition between the 2 signals, I would take another approach. Instead of trying to implement an instantaneous switch at the prefect time, why not doing a progressive switching?
You can multiply the first signal by a signal going smoothly from 1 to 0 and the second one going from 0 to 1 (can be a ramp, or even better a polynomial). I am not sure if this is appropriate for your application, but I used that often.
2 Comments
Rickson
on 21 Jun 2011
Guy Rouleau
on 21 Jun 2011
I am sorry, but this is outside my knowledge of signal processing.
The link you provide seems to be in the right direction.
I already saw active noise control algorithms being able to identify phase and amplitude of one component of a noisy signal, the using this info to artificially generate a reference for a notch filter. You might want to give a try searching in this direction.
Categories
Find more on Signal Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!