フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

code in signal processing

1 回表示 (過去 30 日間)
Filipe
Filipe 2011 年 6 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi people, I have a problem with a code.
A = [ 1 2 3 4]; % amplitude fr = [20 30 40 50]; % frequency
% Number of time samples, and number of samples per FFT Nt = 1024;
% Sampling freqency fs = 1000;
% Frequency spacing df = fs/Nt;
% Time t = [0:Nt-1]/fs;
I want to sum four signals as:
y = A*cos(2*pi*fr*t)
I want to use a FOR to do it, but the A and fr goes until 4 and the t goes until 1024.
I would like to do something
y = 1*cos(2*pi*20*t) + 2*cos(2*pi*30*t) + 3*cos(2*pi*40*t) + 4*cos(2*pi*50*t);
But I want to use a FOR.
How can I do it?
thanks

回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 6 月 24 日
y = zeros(size(t));
for K = 1:length(A)
y = y + A(K) * cos(2*pi*fr(K)*t);
end

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by