-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathramp.m
More file actions
27 lines (22 loc) · 661 Bytes
/
Copy pathramp.m
File metadata and controls
27 lines (22 loc) · 661 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% Program to generate signal of function : x[n] = 2n , -3 <= n <= 3 zero otherwise
clc; clear all;
x = -5:0.0001:5; % Domain, Sampled 0.00001 apart
y = 2.*x; % Point wise multiplication
y (x>3) = 0;
y (x<-3) = 0;
figure('Name','Function Generation','NumberTitle','off','Color','w')
subplot(2,1,1);
plot(x,y,'b'), grid on, grid minor % continuous line 2D plot
title('Continuous')
xlabel('Time')
ylabel('Amplitude')
p = -5:0.2:5; % Domain, Sampled 0.2 sec. apart
q = 2.*p;
q (p>3) = 0;
q (p<-3) = 0;
subplot(2,1,2);
stem(p,q,'r'), grid on, grid minor % Discrete data 2D plot
title('Discrete')
xlabel('Time')
ylabel('Amplitude')
print('-clipboard','-dbitmap')