function varargout = epspi(varargin)
% EPSPI M-file for epspi.fig
% EPSPI, by itself, creates a new EPSPI or raises the existing
% singleton*.
%
% H = EPSPI returns the handle to a new EPSPI or the handle to
% the existing singleton*.
%
% EPSPI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EPSPI.M with the given input arguments.
%
% EPSPI('Property','Value',...) creates a new EPSPI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before epspi_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to epspi_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help epspi
% Last Modified by GUIDE v2.5 19-Jun-2008 12:21:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @epspi_OpeningFcn, ...
'gui_OutputFcn', @epspi_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 epspi is made visible.
function epspi_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 epspi (see VARARGIN)
% Choose default command line output for epspi
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes epspi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = epspi_OutputFcn(hObject, eventdata, handles)
% 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 selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load xxxx.mat
figure
imshow(xxxx)
clear xxxx
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pop=findobj(epspi,'Tag','popupmenu2');
contents=get(pop,'Value');
%Number of samples for the final output signal(SPWM number of samples)
switch(contents)
case 1
NN=1024;
case 2
NN=1024*2;
case 3
NN=1024*4;
case 4
NN=1024*8;
case 5
NN=1024*16;
end
%--------------------------------------------------------------------
%Preparing the sawtooth signal,,,
%Frequency of the sawtooth signal(Hz)
N=NN/2;
counter=0;
%Making the sawtooth signal
for k=1:2*N
counter=ceil(k/(2*N)*100);
clc
sprintf('Percentage Completed = ')
sprintf('%d',counter)
for j=1:50
i=j+(k-1)*50;
wt(i)=i*pi/(N*50);
if rem(k,2)==0
Vt(i)=(0.02*j-0.5)*2;
else
Vt(i)=(1-0.02*j-0.5)*2;
end
end
end
%--------------------------------------------------------------------
%Preparing the plotting areas
figure
subplot(4,1,1)
plot(wt(1:1000),Vt(1:1000),'r')
axis([0,2*pi/100,-1.2,1.2])
grid on
title('Carrier Signal')
%--------------------------------------------------------------------
subplot(4,1,2)
temp=0:2*pi/NN:2*pi;
temp(1)=[];
x=1*sin(temp);
plot(temp,x,'r')
axis([0,2*pi,-1.2,1.2])
grid on
title('Reference Signal')
%--------------------------------------------------------------------
subplot(4,1,3)
plot(wt,Vt,'r')
axis([0,2*pi,-1.2,1.2])
hold on
plot(temp,x,'b')
axis([0,2*pi,-1.2,1.2])
grid on
title('Compination of Carrier & Reference Signals')
%--------------------------------------------------------------------
subplot(4,1,4)
for z=1:length(temp)
if(x(z)>Vt(z))
y(z)=1;
else
y(z)=0;
end
end
plot(temp,y,'*',temp,y,'r')
axis([0,2*pi,-1.2,1.2])
grid on
title('Comparison Result (SPWM)')
set(epspi,'Visible','on')
%--------------------------------------------------------------------
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
pop=findobj(epspi,'Tag','popupmenu2');
contents=get(pop,'Value');
save ccc contents
epspimdl
set(epspi,'Visible','off')