How to introduce a phase shift to a existing vector
44 views (last 30 days)
Show older comments
Hello all,
Kindly help me on this.
I have a existing vector signal of length times. I need to introduce an phase shift to the signal say lag 30 deg.
How to proceed on this?
eg:
t = 0:100e-6:1;
V = sin(2*pi*50*t); % say V is my existing vector signal from Comtrade / TFR or from other sources
Est_V = V *( phaseshift); %% I need to introduce phase shift
Thanks
BS
0 Comments
Answers (3)
Jan
on 4 Aug 2019
This is not possible, if you do not have additional information. You can apply a phase shift with a certain number of elements, or if you have the relation between time and index: about a certain time. But without havinbg the formula, but only the signal, you cannot apply a phase shift, because you do not knwo the frequency. See this:
v = rand(1, 1000);
Now you cannot apply a shift by 30 degree.
2 Comments
Jan
on 5 Aug 2019
Maybe you mean:
t = 0:100e-6:1;
freq = 50; %% hertz
V1 = sin(2*pi*freq*t);
phase = round(numel(t) / freq);
V2 = [zeros(1, phase), V1(1:end-phase)];
plot(t, V1);
hold('on');
plot(t, V2, 'o');
I understand "On plotting V1 & V2, it should match exactly" such that you want a phase shift about 1 period. Number of time steps is not a multiple of the frequency, an 100% phase-shifting is not possible (see the round command).
Xingda Chen
on 6 Nov 2022
Perhaps this is what you are looking for:
p_freq = 5e3; p_period = 1/p_freq; %you have to know your frequency
move_this_many_sampling=round(((phase_i_want_to_shift_in_degree/360)*p_period)/samp_period)% and your sampling rate
off course this would mean you would need to have more data that you want to show in the window (at least +-1 period)
plot(t,real_waveform(1,[window_start:num_item+window_end])) %window_start-- the first sample you want to see/use, window_end-- the last sample you want to see/use, num_item-- the number of samples you want to see/use
hold on
plot(t,real_waveform(1,[window_start+move_this_many_sampling:(num_item+window_start+move_this_many_sampling)]))
I am doing similar task for my project and here is what I got
0 Comments
David Goodmanson
on 8 Nov 2022
I assume that you are given the oscillatory function V in an array, with no accompanying array for the independent variable to set the horizontal scale. In the example, the array has 10001 points and 50 oscillations, so it is a good candidate for the hilbert function. (The hilbert function is not the Hilbert transform, but it makes use of the Hilbert transform. See help hilbert).
t = 0:100e-6:1;
V = sin(2*pi*50*t);
clear t % unknown horizontal scale now
n = length(V)
z = hilbert(V);
a = (unwrap(angle(z)));
V30 = cos(a+pi/6); % 30 degree offset
figure(1)
plot(1:n,V,1:n,V30)
grid on
xlim([4000 5000]) % use just part of the array to expand the plot
ylim([-1.1 1.1])
0 Comments
See Also
Categories
Find more on Transforms 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!