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

11 次查看(过去 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 个评论
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 CenterFile Exchange 中查找有关 Continuous Waveforms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by