How to Generate 5 Sine-waves each at 72° apart but every wave starting at 0.

1 回表示 (過去 30 日間)
Hammad
Hammad 2020 年 5 月 3 日
回答済み: Ameer Hamza 2020 年 5 月 3 日
How to generate a waveform as shown in figure?
  1 件のコメント
dpb
dpb 2020 年 5 月 3 日
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...

サインインしてコメントする。

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 3 日
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 件)

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by