📄 modelta1.m
字号:
%_________________Formulario Modulacion Delta_________________%
function varargout = modelta1(varargin)
% Last Modified by GUIDE v2.5 13-Nov-2006 18:15:14% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @modelta1_OpeningFcn, ...
'gui_OutputFcn', @modelta1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before modelta1 is made visible.
function modelta1_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for modelta1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = modelta1_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;%_______________________________________________________________________%
%_______________________________________________________________________%
set(handles.boton2regresar,'CData',grafico1);
function detalles = grafico1
detalles = imread('pro5.jpg');
% --- Executes on button press in boton1ver.function boton1ver_Callback(hObject, eventdata, handles)
popup_sel_index = get(handles.popupmenu2, 'Value');
switch popup_sel_index
case 1
k=1/5;
case 2
k=8;
case 3
k=1;
end
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
%________________________________DM____________________________________%
f=10; %frecuencia de la se馻l mensaje
ts=1/(10*300); %secuencia finita de muestras espaciadas Ts: periodo de muestreo
fs=1/ts; %frecuencia de muestreo
tfinal=0.125;
t=0:ts:tfinal;
m = sin(2*pi*f*t); %m es la se馻l mensaje
dt=2.5033e-004; %el valor encontrado de dt se logro derivando la se馻l a mano y
%ver el segundo valor correspondiente
% Para encontrar el tama駉 de paso(delta) optimo es necesario obtener
% el maximo valor de la razon de velocidad de cambio de la se馻l mensaje
% la razon de velocidad se obtiene derivando la se馻l mensaje.
% Compute derivada
derm(1)=m(1);
for p = 2:length(m),
derm(p) =(m(p)-m(p-1))/dt;
end
case 2
ts=1/(50*300); %secuencia finita de muestras espaciadas Ts: periodo de muestreo
fs=1/ts; %frecuencia de muestreo
tfinal=0.125;
t=0:ts:tfinal;
m = (exp(-2*pi*5*t).*sin(2*pi*50*t)) + sin(2*pi*4*t); %m es la se馻l mensaje
% Para encontrar el tama駉 de paso(delta) optimo es
% necesario obtener el maximo valor de la razon de
% velocidad de cambio de la se馻l mensaje la razon de
% velocidad se obtiene derivando la se馻l mensaje.
% Compute derivada
derm = 2*pi*exp(-2*pi*5*t).*(50*cos(2*pi*50*t) - 5*sin(2*pi*50*t)) + 8*pi*cos(2*pi*4*t);
end
% calculando el modulo del vector derivada
for i = 1:length(derm),
if derm(i) < 0
modderm(i) = -derm(i);
else
modderm(i) = derm(i);
end
end
% calculando la maxima razon de cambio, el tama駉 de paso optimo
delta = k*ts*(max(modderm));
% Se馻l a cuantizar
% e[n] = m[n] - mq[n-1] luego la cuantizacion de e[n] se obtiene
% eq[n] = delta*sign(e[n])
%mq(n)= sumatoria de los eq, ademas de ser la salida cuantizada es el
%acumulador
%inicializando
e(1) = m(1);
eq(1)= delta*sign(e(1));
mq(1)=eq(1);
% calculando el resto de diferencias entre la se馻l mensaje y la se馻l a la
% salida del acumulador.
for k = 2:length(m),
e(k) = m(k)-mq(k-1);
eq(k)= delta*sign(e(k));
mq(k) = mq(k-1)+eq(k);
end
% modulo de codificacion de bits y de linea.
for j = 1:length(mq),
codi(j) = (5*eq(j))/delta;
end
axes(handles.axes1)
cla;
plot(t,m); title('Se馻l Mensaje / Se馻l M Cuantizada'); hold on; plot(t,mq,'m'); grid on;
axes(handles.axes2)
cla;
plot(t,codi); title('Se馻l Codificada'); grid on;
% --- Executes on button press in boton2regresar.
function boton2regresar_Callback(hObject, eventdata, handles)clear all
close all
close all hidden
proyectocom2
%____________________________________________________________________%% --- Executes during object creation, after setting all properties.function popupmenu1_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)%____________________________________________________________________%
%____________________________________________________________________%% --- Executes during object creation, after setting all properties.function popupmenu2_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on selection change in popupmenu2.function popupmenu2_Callback(hObject, eventdata, handles)%____________________________________________________________________%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -