plot a delta function
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
HADIMARGO
el 18 de Mayo de 2019
Respondida: Ghenam Dahmane
el 10 de Mzo. de 2020
hi guys.
i want to plot this simple delta function.
pls plot this with delta function code.
Respuesta aceptada
Sulaymon Eshkabilov
el 18 de Mayo de 2019
use stem() instead of plot() and you'll get it as shown in your image.
n=-10:10; % E.g. use any space
N1 = 2; % E.g. set up at any value
x = zeros(size(n));
for jj=1:numel(n)
if abs(n(jj))<=N1
x(jj)=1;
else
x(jj)=0;
end
end
stem(n, x)
title('\delta function'), shg
2 comentarios
Sulaymon Eshkabilov
el 18 de Mayo de 2019
Hi Hadimargo,
You are most welcome. It is a pleasure. Good luck.
Más respuestas (2)
Sulaymon Eshkabilov
el 18 de Mayo de 2019
Hi,
here is one of the possible solutions:
n=-10:10; % E.g. use any space
N1 = 2; % E.g. set up at any value
x = zeros(size(n));
for jj=1:numel(n)
if abs(n(jj))<=N1
x(jj)=1;
else
x(jj)=0;
end
end
plot(n, x, 'k-', 'linewidth', 2), grid on
title('\delta function'), shg
Good luck.
Ghenam Dahmane
el 10 de Mzo. de 2020
take this solution
n = -5:1:5;
s = zeros(size(n));
for i = 1:length(n)
if n(i)< -2
s(i) = 0;
elseif -2<=n(i)& n(i)<=2
s(i) = 1;
else
s(i) = 0;
end
end
stem(n,s,'black','Linewidth',1.5), grid on
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!