フィルターのクリア

How to represent digital signal?

20 ビュー (過去 30 日間)
Gokul
Gokul 2013 年 4 月 1 日
回答済み: Riaz Uddin 2022 年 5 月 21 日
How to represent digital signal i.e sequence of 0's and 1's in matlab. and how to plot it
Basically i am trying to represent a switch through a diagram or a plot.
kindly help..!!

回答 (2 件)

Wayne King
Wayne King 2013 年 4 月 1 日
編集済み: Wayne King 2013 年 4 月 1 日
how about just using stem()?
sig = randi([0 1],20,1);
stem(sig,'markerfacecolor',[0 0 1])

Riaz Uddin
Riaz Uddin 2022 年 5 月 21 日
L = 1024;
Periods = 4;
M = 128;
A = 1;
figure,plot( squareWave(L,M,Periods,A) )
function signal = squareWave(L,M,Periods,A)
signal = zeros(L,1); %initialize signal with zeros
if mod(L,Periods) ~= 0
signal = -1; % False input data
end
T = L/Periods; % Get length
% Replace only non-zero values
for idx=1:Periods
signal( 1+(idx-1)*T:1+(idx-1)*T+M) = A;
end
end

カテゴリ

Help Center および File ExchangeSignal Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by