## Add a varying phase shift to a sine wave (linspace involved)

### Andrew (view profile)

on 12 Mar 2014
Latest activity Commented on by Andrew

### Andrew (view profile)

on 12 Mar 2014

Hello,
I have created a sine wave using the linspace function (see below), and using that wave and another one at a different frequency I have created an FSK signal by adding them together. Now I want to add another sine signal to this FSK signal but with a varying phase shift in order to simulate a fading channel.
So far I was just able to add a signal with a constant phase shift therefore my channel is not realistic enough and that is why I want to introduce a varying phase shift. The code used for the constant phase shift follows:
Some limitations are that I do not want to change the linspace function use in order to create the sine wave, as it is a vital component to my program because of the use of samples(total_samples) in order to create graphs and produce good results. Some ideas are the use of for loops and pre-creating a vector of phase shift and then using that to add it to the signal but seems too complicated to implement because of the use of the linspace function. Is there a easier method that I can approach this issue.

### Tags

on 12 Mar 2014

I think you should be able to get what you want by pre-creating a vector of phase shifts. As long as it is the same shape (column vs row, and length) as the original signal, it should work.
For example:
sample_times = linspace(0,2*pi*f1*transmission_time,total_samples);
r = linspace(-0.2, 0.2, total_samples);

Andrew

### Andrew (view profile)

on 12 Mar 2014
Thank you for your fast response. By a few adjustments I got what I pretty much wanted. Thank you for guiding me through the right path!
John D'Errico

### John D'Errico (view profile)

on 12 Mar 2014
um, Note that when you form a sum of two such vectors, both of which are linear sequences, you do NOT get a phase shift!!! A phase shifted series should have the same frequency as the old series. Note that the plots as shown do NOT. My point is, this answer does NOT provide a uniform phase shift.
Andrew

### Andrew (view profile)

on 12 Mar 2014
Dear John,
I don't exactly understand what you mean, but after some tests with just this part of my program I am getting what I want. And even in the main program the code seems to work fine, I am getting bit errors after decoding the fsk signal due to the fact that sometimes the signal with frequency f1 has been cancelled out due to this fading signal( which at some point it will be at 180 out of phase) causing these desirable wrong decisions in the decoder. Let me demonstrate using the following code:
z = (1:10000);
total_samples = 10000;
f1=1;
transmission_time = 5;
sample_times = linspace(0,2*pi*f1*transmission_time,total_samples);