How can i see the optical spectrum of Modulation techniques(i.e; OOK,DPSK,DQPSK,QAM ,RZ & NRZ) on the axes .in replace of the given signal show in the axes..
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
code gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled3_OpeningFcn, ... 'gui_OutputFcn', @untitled3_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(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 untitled3 is made visible. function untitled3_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to untitled3 (see VARARGIN)
% Choose default command line output for untitled3 handles.output = hObject;
handles.count=0; % what is handles.count doing? we introduce them on the range 1,50 handles.bww= zeros(1,50); handles.f00= zeros(1,50); handles.w11= zeros(1,50); handles.w22= zeros(1,50); handles.width= zeros(1,50); handles.s=0; handles.c=0; handles.l=0; %handles.OOK=0;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes untitled3 wait for user response (see UIRESUME) %uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = untitled3_OutputFcn(hObject, eventdata, handles) % VARARGOUT must be % declared as the last output argument and must contain all the % outputs after that point onwards. % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure varargout{1} = handles.output;
% --- Executes on button press in Generate. function Generate_Callback(hObject, eventdata, handles) % hObject handle to Generate (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
bw=str2num(get(handles.bw,'String')); %String — a cell array that contains the menu contents %f0=str2num(get(handles.f0,'String')); % strng to num conversion l=str2num(get(handles.frequency,'String')); m=get(handles.frequency,'value'); % takes freq. value f0=l(m); % f0 is center frequency
y=0; z=0; %x=0;0 for k=1:50
if handles.f00(k)==f0 % it means that if we give freq again after give it once so it shows msg
%msgbox('Center Frequency Already Occupied')
z=1;
end
end
switch z
case 0
handles.count=handles.count+1;
i=handles.count; %no of values insert into handles
handles.bww(i)=bw; % value of bandwidth spacing
handles.f00(i)=f0; % value of center frequency
bw=bw*1e9; % giga hertz
f0=f0*1e12; % Tera hertz
q=f0/bw; % quality factor ... f0 selects by user ( means we give a center freq to gui and it will design the center freq plot a/c to
f1=f0*(sqrt(1+1/(4*q^2))-1/(2*q)); % lower cutoff frequency of bandwidth
w2=3e8/f1; %wavelength of lower cut off freq. w=c/f where c=3*exp8
f2=f0*(sqrt(1+1/(4*q^2))+1/(2*q)); % upper cutoff frequency of bandwidth
w1=3e8/f2; % wavelenghtof upper cut off freq.
handles.w11(i)=w1;
handles.w22(i)=w2;
width=w2-w1; %channel width
handles.width(i)=width; %
%axes(handles.axes1);
%rectangle('position',[w1,0,width,4],'FaceColor','g');
if handles.s==1
axes(handles.axes1); %access the handle.axes1 or we can say that we plot a rectangle on axes
rectangle('position',[w1,0,width,4],'FaceColor','g'); %We give height of 4 ,width =w2-w1,y axis=0 ,x axis shows upper cutoff freq wavelength (but why we give w1?)
axis([1460e-9,1530e-9,0,7]); % axis :scaling and appearance Syntax axis([xmin xmax ymin ymax])
elseif handles.c==1
axes(handles.axes1);
rectangle('position',[w1,0,width,4],'FaceColor','y');
axis([1530e-9,1565e-9,0,7]);
elseif handles.l==1
axes(handles.axes1);
rectangle('position',[w1,0,width,4],'FaceColor','g');
axis([1565e-9,1625e-9,0,7]);
end
xlabel('wavelength');
ylabel('power');
guidata(hObject, handles); %save the changed version of handles with the command guidata(object_handle,handles).
case 1
handles.count=handles.count+1;
i=handles.count; %no of values insert into handles
handles.bww(i)=bw; % value of bandwidth spacing
handles.f00(i)=f0; % value of center frequency
bw=bw*1e9; % giga hertz
f0=f0*1e12; % Tera hertz
q=f0/bw; % quality factor ... f0 selects by user ( means we give a center freq to gui and it will design the center freq plot a/c to
f1=f0*(sqrt(1+1/(4*q^2))-1/(2*q)); % lower cutoff frequency of bandwidth
w2=3e8/f1; %wavelength of lower cut off freq. w=c/f where c=3*exp8
f2=f0*(sqrt(1+1/(4*q^2))+1/(2*q)); % upper cutoff frequency of bandwidth
w1=3e8/f2; % wavelenghtof upper cut off freq.
handles.w11(i)=w1;
handles.w22(i)=w2;
width=w2-w1; %channel width
handles.width(i)=width; %
%axes(handles.axes1);
%rectangle('position',[w1,0,width,4],'FaceColor','g');
if handles.s==1
axes(handles.axes1); %access the handle.axes1 or we can say that we plot a rectangle on axes
rectangle('position',[w1,0,width,4],'FaceColor','r'); %We give height of 4 ,width =w2-w1,y axis=0 ,x axis shows upper cutoff freq wavelength (but why we give w1?)
axis([1460e-9,1530e-9,0,7]); % axis :scaling and appearance Syntax axis([xmin xmax ymin ymax])
elseif handles.c==1
axes(handles.axes1);
rectangle('position',[w1,0,width,4],'FaceColor','r');
axis([1530e-9,1565e-9,0,7]);
elseif handles.l==1
axes(handles.axes1);
rectangle('position',[w1,0,width,4],'FaceColor','r');
axis([1565e-9,1625e-9,0,7]);
end
xlabel('wavelength');
ylabel('power');
guidata(hObject, handles);
%msgbox('Center Frequency Already Occupied')
end
xlabel('wavelength');
ylabel('power');
guidata(hObject, handles);
function bw_Callback(hObject, eventdata, handles) % hObject handle to bw (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of bw as text % str2double(get(hObject,'String')) returns contents of bw as a double
% --- Executes during object creation, after setting all properties. function bw_CreateFcn(hObject, eventdata, handles) % hObject handle to bw (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% % function f0_Callback(hObject, eventdata, handles) % % hObject handle to f0 (see GCBO) % % eventdata reserved - to be defined in a future version of MATLAB % % handles structure with handles and user data (see GUIDATA) % % % Hints: get(hObject,'String') returns contents of f0 as text % % str2double(get(hObject,'String')) returns contents of f0 as a double % % % % --- Executes during object creation, after setting all properties. % function f0_CreateFcn(hObject, eventdata, handles) % % hObject handle to f0 (see GCBO) % % eventdata reserved - to be defined in a future version of MATLAB % % handles empty - handles not created until after all CreateFcns called % % % Hint: edit controls usually have a white background on Windows. % % See ISPC and COMPUTER. % if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) % set(hObject,'BackgroundColor','white'); % end
% --- Executes on button press in Defragment. function Defragment_Callback(hObject, eventdata, handles) % hObject handle to Defragment (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
delete(handles.text5)
j=handles.count; % i.e j=2
if handles.s==1 w=1460.5e-9; for i=1:j width=handles.width(i); % width will be equal to axes(handles.axes2); rectangle('position',[w,0,width,4],'FaceColor','g'); axis([1460e-9,1530e-9,0,7]); xlabel('wavelength'); ylabel('power'); guidata(hObject, handles); w=w+width+0.5e-9;
end
elseif handles.c==1 w=1530.5e-9; for i=1:j width=handles.width(i); axes(handles.axes2); rectangle('position',[w,0,width,4],'FaceColor','g'); axis([1530e-9,1565e-9,0,7]); xlabel('wavelength'); ylabel('power'); guidata(hObject, handles); %save the changed version of handles with the command guidata(object_handle,handles). w=w+width+0.5e-9; %1530.5e-9+ channel width +0.5e-9 i.e defragmentation
end elseif handles.l==1 w=1565.5e-9; for i=1:j width=handles.width(i); axes(handles.axes2); rectangle('position',[w,0,width,4],'FaceColor','g'); axis([1565e-9,1625e-9,0,7]); xlabel('wavelength'); ylabel('power'); guidata(hObject, handles); w=w+width+0.5e-9;
end end
%handles.w11(i) %handles.w22(i)
% --- Executes when selected object is changed in uipanel3. function uipanel3_SelectionChangeFcn(hObject, eventdata, handles) % bands ui panel (s , c , l bands) % hObject handle to the selected object in uipanel3 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) if hObject==handles.SBand handles.s=1; handles.c=0; handles.l=0; spac=str2num(get(handles.bw,'String')); spac=spac/1000; text=196.20:spac:201.10; set(handles.frequency,'String',text); elseif hObject==handles.CBand handles.c=1; handles.s=0; handles.l=0; spac=str2num(get(handles.bw,'String')); spac=spac/1000; text=191.20:spac:196.10; set(handles.frequency,'String',text); elseif hObject==handles.LBand handles.l=1; handles.c=0; handles.s=0; spac=str2num(get(handles.bw,'String')); spac=spac/1000; text=186.20:spac:191.10; set(handles.frequency,'String',text); end
%text=[12 13]; %set(handles.frequency,'String',text); guidata(hObject, handles);
% --- Executes on selection change in frequency. function frequency_Callback(hObject, eventdata, handles) % hObject handle to frequency (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns frequency contents as cell array % contents{get(hObject,'Value')} returns selected item from frequency
% --- Executes during object creation, after setting all properties. function frequency_CreateFcn(hObject, eventdata, handles) % hObject handle to frequency (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Delete. function Delete_Callback(hObject, eventdata, handles) % hObject handle to Delete (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % src - the object that is the source of the event % evnt - empty for this property
g=findobj('FaceColor','r');
delete(g);
% --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in popupmenumodulated. function popupmenumodulated_Callback(hObject, eventdata, handles) % hObject handle to popupmenumodulated (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenumodulated contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenumodulated ;
popupmenumodulated = get(hObject,'Value'); string_list = get(hObject,'String'); selected_string = string_list{popupmenumodulated};
switch popupmenumodulated case 1
axes(handles.axes1);
fs = 100; % Sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 sec sample
x = (1.3)*sin(2*pi*15*t) ... % 15 Hz component
+ (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component
+ (2.5)*randn(size(t)); % Gaussian noise;
%Use fft to compute the DFT y and its power: m = length(x); % Window length n = pow2(nextpow2(m)); % Transform length y = fft(x,n); % DFT f = (0:n-1)*(fs/n); % Frequency range power = y.*conj(y)/n; % Power of the DFT
plot(f,power) xlabel('Frequency (Hz)') ylabel('Power') title('{\bf Periodogram}')
%freq versus power plot is called periodogram
case 2
axes(handles.axes1);
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t)); % Sinusoids plus noise
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum. plot(f,2*abs(Y(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of y(t)') xlabel('Frequency (Hz)') ylabel('|Y(f)|')
case 3
o
end
%handles.popupmenumodulated= popupmenumodulated;
set(handles.popupmenu1,'Value') ;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties. function popupmenumodulated_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenumodulated (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes during object creation, after setting all properties. function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
0 Commenti
Risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!