Created
May 5, 2016 07:36
-
-
Save juanbono/327d5266903c3d81133593dbd3747097 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Borrar todo de la consola % | |
clc; | |
clear all; | |
close all; | |
fm = input('Frecuencia mensaje = '); | |
fc = input('Frecuencia funcion sierra = '); | |
A = input('Amplitud funcion sierra = '); | |
tmax = input('Tiempo = '); | |
t = 0:0.001:tmax; % Rango del tiempo - entre 0 y un tiempo maximo % | |
c = A.*sawtooth(2*pi*fc*t); % Funcion sierra % | |
subplot(3,1,1); | |
plot(t,c); | |
xlabel('Tiempo'); | |
ylabel('Amplitud'); | |
title('Funcion Sierra'); | |
grid on; | |
m = A.*sin(2*pi*fm*t); % Funcion mensaje % | |
subplot(3,1,2); | |
plot(t,m); | |
xlabel('Tiempo'); | |
ylabel('Amplitud'); | |
title('Funcion Mensaje'); | |
grid on; | |
n = length(c); | |
for i = 1:n % Se comparan las amplitudes para armar la pwm % | |
if (m(i)>=c(i)) | |
pwm(i)=1; | |
else | |
pwm(i)=0; | |
end | |
end | |
subplot(3,1,3); | |
plot(t,pwm); | |
xlabel('Tiempo'); | |
ylabel('Amplitud'); | |
title('PWM'); | |
axis([0 tmax 0 2]); % Para variar los ejes del grafico de pwm % | |
grid on; | |
% Parte para ver ppm % | |
for i = 1:n | |
if (pwm(i)==0) | |
ppm(i)=1; | |
end | |
end | |
subplot(3,2,1) | |
plot(t,ppm); | |
xlabel('Tiempo'); | |
ylabel('Amplitud'); | |
title('PPM'); | |
axis([0 tmax 0 2]); % Para variar los ejes del grafico de pwm % | |
grid on; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment