Combine a waveform from a set of sine waves which are linearly increasing in frequency

17 ビュー (過去 30 日間)
Hi,
I generate and plot multiple waveforms which have increasing frequency. I want to combine them at each time interval of t, but how? Please share if you know how...
for f = 1:1:200 % Upto 200 Hz
t=[0 : 0.01 : 1]
y=sin (2 * pi .* f .* t);
hold on
plot (t,y)
end
thanks

採用された回答

Star Strider
Star Strider 2017 年 11 月 2 日
Try this:
t = 0 : 0.01 : 1;
for f = 1:1:200 % Upto 200 Hz
y(f,:) = sin (2 * pi .* f .* t);
end
plot (t,y)
hold on
plot(t, sum(y), ':r', 'LineWidth',2.5)
hold off
The sum is essentially zero for all columns.
  9 件のコメント
Nathan Kennedy
Nathan Kennedy 2017 年 11 月 3 日
The comment about fft is something I would like to add in
Star Strider
Star Strider 2017 年 11 月 3 日
You will find this documentation for the fft (link) function helpful.
Example
t = 0 : 0.01 : 1;
for f = 1 : 2 % Upto 2 Hz
y(f,:) = sin (2 * pi .* f .* t);
end
figure(1)
plot(t,y)
hold on
plot(t, sum(y), ':r', 'LineWidth',2.5)
hold off
L = length(t); % Signal Length
Ts = t(2) - t(1); % Sampling Time Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
Fourier = fft(y, [], 2)/L; % Fourier Transform (Along Rows Of Matrix)
figure(2)
subplot(2,1,1)
plot(Fv, abs(Fourier(:,Iv))*2)
title('Amplitude')
grid
subplot(2,1,2)
plot(Fv, angle(Fourier(:,Iv)))
title('Phase')
xlabel('Frequency')
grid
The time-domain plots are in figure(1) and the frequency-domain plots are in figure(2).

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by