Vous êtes sur la page 1sur 3

%Practical 6:- Energy calculation of Signal (Ramp)

%[ We calculate Energy of Aperiodic signals ]


clc;
close all;

t=-1:.01:1;
x=t; % Ramp Signal...
figure(1);
plot(t,x);
grid;
xlabel('t');
ylabel('x(t)');

figure(2);
plot(t,x.^2);
xlabel('t');
ylabel('x^2(t)');
title('Energy of Ramp signal')
axis([-1 1 -.2 2]);
grid;

figure(3);
area(t,x.^2); % Energy is nothing but Area calculation...
xlabel('t');
ylabel('x^2(t)');
title('The colored area gives the energy')
axis([-1 1 -.2 1.1]);
grid;
Make a program free:
Make an Electronics Project than Contact:
hardikbrainmaster@yahoo.com
hardiksimpleec@gmail.com

%Power calculation of analog and time discrete Sine signal


clc;
t=-2:0.01:2;
x1=sin(2*pi*t);
n=-40:40;
x2=sin(pi*(1/10)*n);
%----------------------------------
figure(1);
%-----------------
subplot(2,1,1)
plot(t,x1); % Signal X1
grid on;
title('Analog & Discrete sine');
xlabel('t');
ylabel('x_1(t)');

subplot(2,1,2);
stem(n,x2); % Signal X2
grid on;
xlabel('n');
ylabel('x_2(n)');
%----------------------------------
figure(2);
subplot(2,1,1);
plot(t,x1.^2); % Energy of X1
grid on;
hold on
% red lines marking 0 & 1
plot([0 0], [-.2 1.2],'r', [1 1], [-.2 1.2],'g');
%hold off
axis([-2 2 -.2 1.2]);
title('Squared sines');
xlabel('t');
ylabel('x_1^2(t)');

subplot(2,1,2);
stem(n,x2.^2); % Energy of X2
grid on;
hold on;
% red lines marking 1 & 20
plot([1 1], [-.2 1.2],'r', [20 20], [-.2 1.2],'g');
hold off;
axis([-40 40 -.2 1.2]);
xlabel('n');
ylabel('x_2^2(n)');

%calculating power of one period of X1.


%disp('Power, one period:');
%P1 = (1/1)*sum(x1(1:1).^2)

%calculating power of one period of X2.


disp('Power, one period:');
P2 = (1/20)*sum(x2(1:20).^2)

Vous aimerez peut-être aussi