eedre85
Electrical
- Nov 28, 2006
- 3
Hello,
I'd like to generate a function:
x(t) = rect[(t-1)/2]
therefore,
x(t) = 1; 0<=t<=2
x(t) = 0; otherwise
I've tried sampling using a for loop, but I can't seem to create a graphable collection of points ( I always end up with one point). What's the solution?
Here's a sample of my code:
clc;
w = -10:0.05:10;
t = -4:0.01:4;
x = 0;
X = 2*sinc(w/pi).*exp(-j*w);
%plot (w, X);
%xlabel('w');
%ylabel('X(w)');
if 0<=t<=2
x = 1;
else
x = 1;
end
plot (t,x);
This code gives me a straight line at 1 within my window.
I'd like to generate a function:
x(t) = rect[(t-1)/2]
therefore,
x(t) = 1; 0<=t<=2
x(t) = 0; otherwise
I've tried sampling using a for loop, but I can't seem to create a graphable collection of points ( I always end up with one point). What's the solution?
Here's a sample of my code:
clc;
w = -10:0.05:10;
t = -4:0.01:4;
x = 0;
X = 2*sinc(w/pi).*exp(-j*w);
%plot (w, X);
%xlabel('w');
%ylabel('X(w)');
if 0<=t<=2
x = 1;
else
x = 1;
end
plot (t,x);
This code gives me a straight line at 1 within my window.