How to Generate 5 Sine-waves each at 72° apart but every wave starting at 0.
2 views (last 30 days)
Show older comments
How to generate a waveform as shown in figure?
1 Comment
dpb
on 3 May 2020
Something else going on besides just a phase shift, though, in the figure.
There's some sort of transient in the first cycle that ramps up the amplitude with some overshoot of the steady-state magnitudes. W/O knowing what that was/is it's a shot in the dark.
A simple phase shift alone would be easy enough...
Accepted Answer
Ameer Hamza
on 3 May 2020
One of the easiest ways I can think of is to use a continuous-time filter, with initial conditions set to zero. The only caveat is the attenuation in the magnitude of the sine wave and a bit of shift in the absolute phase. The relative phase difference is still 72 degrees. The magnitude attenuation can be corrected by multiplying it with a factor as done in the following code.
This code requires the control system toolbox. The same can be done with ode45.
t = linspace(0, 3, 1000); % time vector
freq = 1; % 1 Hz
phases = 0:deg2rad(72):deg2rad(72)*5; % phase shifts, multiple of
y = sin(2*pi*freq*t + phases.'); % each row is a sine wave
% create and apply the filter
filter_freq = 3;
fil = tf(2*pi*filter_freq, [1 2*pi*filter_freq]); % create a filter
y_fil = zeros(size(y));
for i=1:size(y,1)
y_fil(i, :) = lsim(fil, y(i,:), t);
end
mul_factor = sqrt((2*pi*freq)^2+(2*pi*filter_freq)^2)/(2*pi*filter_freq); % filter attenuation factor
y_fil = mul_factor*y_fil;
plot(t, y_fil)
0 Comments
More Answers (0)
See Also
Categories
Find more on Filter Analysis 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!