필터 지우기
필터 지우기

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

조회 수: 12 (최근 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 CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by