Construct a square wave

4 ビュー (過去 30 日間)
Rytis Beinarys
Rytis Beinarys 2018 年 3 月 28 日
編集済み: Rytis Beinarys 2022 年 1 月 23 日
I am given this:
sampFreq = 15000; % sampling frequency, this value should be over twice the largest frequency comp, of signals
T = 1/sampFreq;
t = 0:T:2; % sampling time
%st variables
a_s = 1; % amplitude
f_s = 60; % frequency
ph_s = pi; % phase angle
c_s = 1; % constant off set
st = my_sin(t,a_s,f_s,ph_s,c_s);
figure(1);clf
subplot(2,1,1);plot(t,st,'b');
xlabel('Time (sec)');
ylabel('Amplitude');
title('Data Signal')
xlim([min(t),max(t)]);
ylim([min(st),max(st)])
adjfig();

採用された回答

Shounak Shastri
Shounak Shastri 2018 年 3 月 29 日
I cannot give you the exact code because its a homework assignment. But this should lead you towards the answer.
So the signal s(t) is the sinusoidal signal which you have been given. You are told to construct another signal f(t) which should be a square wave with the given parameters.
You can use the function "square" (check the documentation) or alternatively you can generate a random stream of binary bits using randi([0,1],x,y) and sample it using your sampling frequency.
Best of Luck!

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by