フィルターのクリア

Plotting discontinuous discrete signal with shift and fold

4 ビュー (過去 30 日間)
Miza
Miza 2011 年 2 月 23 日
回答済み: Deepak 2024 年 2 月 28 日
Hello !
I have a given question below
x[n]= {1+n/3 -3<=n<=-1,
1 0<=n<=3,
0 other wise}
I have to plot this signal and I have developed the following code for that
clc
n=-10:1:10;
for i=1:length(n)
if n(i)>=-3 && n(i)<=-1
x(i)=1+(n(i)/3);
elseif n(i)>=1 && n(i)<=3
x(i)=1;
else
x(i)=0;
end
stem(x)
end
axis([-20 20 0 2])
but the resulting waveform is plotted for positive values of n, Kindly help me to plot the above sequence,

回答 (4 件)

Gnaneswar Nadh satapathi
Gnaneswar Nadh satapathi 2013 年 11 月 6 日
clc clear all close all n=-10:1:10; for i=1:length(n) if n(i)>=-3 && n(i)<=-1 x(i)=1+(n(i)/3); elseif n(i)>=1 && n(i)<=3 x(i)=1; else x(i)=0; end
end stem(n,x)
  1 件のコメント
Gnaneswar Nadh satapathi
Gnaneswar Nadh satapathi 2013 年 11 月 6 日
write stem outside rather than inside the loop

サインインしてコメントする。


Sk Group
Sk Group 2021 年 2 月 8 日
MATLAB CODE:
function [n1,x1] = sigshift(x,n,k)
n = 1:10;
k = 2;
x = exp(n);
if k>0
disp(‘Positive’);
n1 = n(1):n(end)+k;
x1 = [zeros(1,k) x];
else
disp(‘Negative’);
n1 = n(1)+k:n(end);
x1 = [x zeros(1,abs(k))]; % abs is for absolute value of (k) because quantity can never be (-ve) negative %
end
MATLAB CODE:
function [y n1] = sigfold(x,n)
n1 = -fliplr(n)
y = fliplr(x)
end
  1 件のコメント
Kunal
Kunal 2023 年 7 月 27 日
discrete time signal folding code

サインインしてコメントする。


Kunal
Kunal 2023 年 7 月 27 日
discrete time signal folding code

Deepak
Deepak 2024 年 2 月 28 日
how to folda given signal

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by