www.gusucode.com > 基于matlab编程PSPL算法GUI界面设计系统源码程序 > 基于matlab编程PSPL算法GUI界面设计系统源码程序/code/PSPL.m
function varargout = PSPL(varargin) % PSPL M-file for PSPL.fig % PSPL, by itself, creates a new PSPL or raises the existing % singleton*. % % H = PSPL returns the handle to a new PSPL or the handle to % the existing singleton*. % % PSPL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in PSPL.M with the given input arguments. % % PSPL('Property','Value',...) creates a new PSPL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before PSPL_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to PSPL_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 PSPL % Last Modified by GUIDE v2.5 29-Nov-2015 02:10:11 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @PSPL_OpeningFcn, ... 'gui_OutputFcn', @PSPL_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 PSPL is made visible. function PSPL_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 PSPL (see VARARGIN) % Choose default command line output for PSPL handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes PSPL wait for user response (see UIRESUME) % uiwait(handles.figure1); h1=handles.axes1; h2=handles.axes3; h3=handles.axes4; h4=handles.axes5; h5=handles.axes2; title(h1,'Phase Voltage & Current') compass(h1,0,0) compass(h2,0,0) compass(h3,0,0) compass(h4,0,0) % --- Outputs from this function are returned to the command line. function varargout = PSPL_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; function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (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 edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (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 edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (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 edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (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 edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (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 edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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 edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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 edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (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 edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double % --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (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 edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (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 edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double % --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (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 edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (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 edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (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 edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (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 edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double % --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (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 edit10_Callback(hObject, eventdata, handles) % hObject handle to edit10 (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 edit10 as text % str2double(get(hObject,'String')) returns contents of edit10 as a double % --- Executes during object creation, after setting all properties. function edit10_CreateFcn(hObject, eventdata, handles) % hObject handle to edit10 (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 edit11_Callback(hObject, eventdata, handles) % hObject handle to edit11 (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 edit11 as text % str2double(get(hObject,'String')) returns contents of edit11 as a double % --- Executes during object creation, after setting all properties. function edit11_CreateFcn(hObject, eventdata, handles) % hObject handle to edit11 (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 edit12_Callback(hObject, eventdata, handles) % hObject handle to edit12 (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 edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double % --- Executes during object creation, after setting all properties. function edit12_CreateFcn(hObject, eventdata, handles) % hObject handle to edit12 (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 edit13_Callback(hObject, eventdata, handles) % hObject handle to edit13 (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 edit13 as text % str2double(get(hObject,'String')) returns contents of edit13 as a double % --- Executes during object creation, after setting all properties. function edit13_CreateFcn(hObject, eventdata, handles) % hObject handle to edit13 (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 edit14_Callback(hObject, eventdata, handles) % hObject handle to edit14 (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 edit14 as text % str2double(get(hObject,'String')) returns contents of edit14 as a double % --- Executes during object creation, after setting all properties. function edit14_CreateFcn(hObject, eventdata, handles) % hObject handle to edit14 (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 edit15_Callback(hObject, eventdata, handles) % hObject handle to edit15 (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 edit15 as text % str2double(get(hObject,'String')) returns contents of edit15 as a double % --- Executes during object creation, after setting all properties. function edit15_CreateFcn(hObject, eventdata, handles) % hObject handle to edit15 (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 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) clc; global V_R0 V_R1 V_R2 I_R0 I_R1 I_R2; global V_Y0 V_Y1 V_Y2 I_Y0 I_Y1 I_Y2; global V_B0 V_B1 V_B2 I_B0 I_B1 I_B2; global vol_R vol_Y vol_B; global cur_R cur_Y cur_B; global C P Q; global t; display('Symmetrical Componet progrom running...'); h1=handles.axes1; axes(handles.axes1); V_R_mag_str=get(handles.edit1,'String'); V_R_pha_str=get(handles.edit2,'String'); V_R_mag=str2double(V_R_mag_str); V_R_pha=str2double(V_R_pha_str); r_V_R=V_R_mag*cosd(V_R_pha); i_V_R=V_R_mag*sind(V_R_pha); compass(h1,r_V_R,i_V_R,'Red'); v=strcat('V_R = ',V_R_mag_str,' < ',V_R_pha_str,' V'); set(handles.text26,'String',v); zoom on; zoom out; hold on; V_Y_mag_str=get(handles.edit3,'String'); V_Y_pha_str=get(handles.edit4,'String'); V_Y_mag=str2double(V_Y_mag_str); V_Y_pha=str2double(V_Y_pha_str); r_V_Y=V_Y_mag*cosd(V_Y_pha); i_V_Y=V_Y_mag*sind(V_Y_pha); compass(h1,r_V_Y,i_V_Y,'Yellow'); v=strcat('V_Y = ',V_Y_mag_str,' < ',V_Y_pha_str,' V'); set(handles.text27,'String',v); zoom on; zoom out; hold on; V_B_mag_str=get(handles.edit5,'String'); V_B_pha_str=get(handles.edit6,'String'); V_B_mag=str2double(V_B_mag_str); V_B_pha=str2double(V_B_pha_str); r_V_B=V_B_mag*cosd(V_B_pha); i_V_B=V_B_mag*sind(V_B_pha); compass(r_V_B,i_V_B,'Blue'); v=strcat('V_B = ',V_B_mag_str,' < ',V_B_pha_str,' V'); set(handles.text28,'String',v); zoom on; zoom out hold on; I_R_mag_str=get(handles.edit7,'String'); I_R_pha_str=get(handles.edit8,'String'); I_R_mag=str2double(I_R_mag_str); I_R_pha=str2double(I_R_pha_str); r_I_R=I_R_mag*cosd(I_R_pha); i_I_R=I_R_mag*sind(I_R_pha); compass(r_I_R,i_I_R,'Red'); v=strcat('I_R = ',I_R_mag_str,' < ',I_R_pha_str,' A'); set(handles.text44,'String',v); zoom on; zoom out hold on; I_Y_mag_str=get(handles.edit9,'String'); I_Y_pha_str=get(handles.edit10,'String'); I_Y_mag=str2double(I_Y_mag_str); I_Y_pha=str2double(I_Y_pha_str); r_I_Y=I_Y_mag*cosd(I_Y_pha); i_I_Y=I_Y_mag*sind(I_Y_pha); compass(r_I_Y,i_I_Y,'Yellow'); v=strcat('I_Y = ',I_Y_mag_str,' < ',I_Y_pha_str,' A'); set(handles.text45,'String',v); zoom on; zoom out hold on; I_B_mag_str=get(handles.edit11,'String'); I_B_pha_str=get(handles.edit12,'String'); I_B_mag=str2double(I_B_mag_str); I_B_pha=str2double(I_B_pha_str); r_I_B=I_B_mag*cosd(I_B_pha); i_I_B=I_B_mag*sind(I_B_pha); compass(r_I_B,i_I_B,'Blue'); v=strcat('I_B = ',I_B_mag_str,' < ',I_B_pha_str,' A'); set(handles.text46,'String',v); zoom on; zoom out hold on; hold off; a=-0.5+0.866j; A=(1/3)*[1 1 1; 1 a^2 a; 1 a a^2]; global V_in I_in; V_in=[r_V_R+i_V_R*j r_V_Y+i_V_Y*j r_V_B+i_V_B*j]; I_in=[r_I_R+i_I_R*j r_I_Y+i_I_Y*j r_I_B+i_I_B*j]; V_R_x=(A*[r_V_R+i_V_R*j r_V_Y+i_V_Y*j r_V_B+i_V_B*j]')'; V_R0 =V_R_x(1); V_R1 =V_R_x(2); V_R2 =V_R_x(3); I_R_x=(A*[r_I_R+i_I_R*j r_I_Y+i_I_Y*j r_I_B+i_I_B*j]')'; I_R0 =I_R_x(1); I_R1 =I_R_x(2); I_R2 =I_R_x(3); V_Y_x=[V_R0 a^2*V_R1 a*V_R2]; V_Y0 =V_Y_x(1); V_Y1 =V_Y_x(2); V_Y2 =V_Y_x(3); I_Y_x=[I_R0 a^2*I_R1 a*I_R2]; I_Y0 =I_Y_x(1); I_Y1 =I_Y_x(2); I_Y2 =I_Y_x(3); V_B_x=[V_R0 a*V_R1 a^2*V_R2]; V_B0 =V_B_x(1); V_B1 =V_B_x(2); V_B2 =V_B_x(3); I_B_x=[I_R0 a*I_R1 a^2*I_R2]; I_B0 =I_B_x(1); I_B1 =I_B_x(2); I_B2 =I_B_x(3); h2=handles.axes3; axes(handles.axes3); V_R_mag_str0=(real(V_R0)^2+imag(V_R0)^2)^(1/2); V_R_pha_str0=atan2d(imag(V_R0),real(V_R0)); compass(h2,V_R0,'Red'); v=strcat('V_R0 = ',num2str(V_R_mag_str0,'%10.2e'),' < ',num2str(V_R_pha_str0,'%4.2f'),' V'); set(handles.text47,'String',v); zoom on; zoom out hold on; V_Y_mag_str0=(real(V_Y0)^2+imag(V_Y0)^2)^(1/2); V_Y_pha_str0=atan2d(imag(V_Y0),real(V_Y0)); compass(V_Y0,'Yellow'); v=strcat('V_Y0 = ',num2str(V_Y_mag_str0,'%10.2e'),' < ',num2str(V_Y_pha_str0,'%4.2f'),' V'); set(handles.text48,'String',v); zoom on; zoom out hold on; V_B_mag_str0=(real(V_B0)^2+imag(V_B0)^2)^(1/2); V_B_pha_str0=atan2d(imag(V_B0),real(V_B0)); compass(V_B0,'Blue'); v=strcat('V_B0 = ',num2str(V_B_mag_str0,'%10.2e'),' < ',num2str(V_B_pha_str0,'%4.2f'),' V'); set(handles.text49,'String',v); zoom on; zoom out hold on; I_R_mag_str0=(real(I_R0)^2+imag(I_R0)^2)^(1/2); I_R_pha_str0=atan2d(imag(I_R0),real(I_R0)); compass(I_R0,'Red'); v=strcat('I_R0 = ',num2str(I_R_mag_str0,'%10.2e'),' < ',num2str(I_R_pha_str0,'%4.2f'),' A'); set(handles.text50,'String',v); zoom on; zoom out hold on; I_Y_mag_str0=(real(I_Y0)^2+imag(I_Y0)^2)^(1/2); I_Y_pha_str0=atan2d(imag(I_Y0),real(I_Y0)); compass(I_Y0,'Yellow'); v=strcat('I_Y0 = ',num2str(I_Y_mag_str0,'%10.2e'),' < ',num2str(I_Y_pha_str0,'%4.2f'),' A'); set(handles.text51,'String',v); zoom on; zoom out hold on; I_B_mag_str0=(real(I_B0)^2+imag(I_B0)^2)^(1/2); I_B_pha_str0=atan2d(imag(I_B0),real(I_B0)); compass(I_B0,'Blue'); v=strcat('I_B0 = ',num2str(I_B_mag_str0,'%10.2e'),' < ',num2str(I_B_pha_str0,'%4.2f'),' A'); set(handles.text52,'String',v); zoom on; zoom out hold on; hold off; h3=handles.axes4; axes(handles.axes4); V_R_mag_str1=(real(V_R1)^2+imag(V_R1)^2)^(1/2); V_R_pha_str1=atan2d(imag(V_R1),real(V_R1)); compass(h3,V_R1,'Red'); v=strcat('V_R1 = ',num2str(V_R_mag_str1,'%10.2e'),' < ',num2str(V_R_pha_str1,'%4.2f'),' V'); set(handles.text53,'String',v); zoom on; zoom out hold on; V_Y_mag_str1=(real(V_Y1)^2+imag(V_Y1)^2)^(1/2); V_Y_pha_str1=atan2d(imag(V_Y1),real(V_Y1)); compass(V_Y1,'Yellow'); v=strcat('V_Y1 = ',num2str(V_Y_mag_str1,'%10.2e'),' < ',num2str(V_Y_pha_str1,'%4.2f'),' V'); set(handles.text54,'String',v); zoom on; zoom out hold on; V_B_mag_str1=(real(V_B1)^2+imag(V_B1)^2)^(1/2); V_B_pha_str1=atan2d(imag(V_B1),real(V_B1)); compass(V_B1,'Blue'); v=strcat('V_B1 = ',num2str(V_B_mag_str1,'%10.2e'),' < ',num2str(V_B_pha_str1,'%4.2f'),' V'); set(handles.text55,'String',v); zoom on; zoom out hold on; I_R_mag_str1=(real(I_R1)^2+imag(I_R1)^2)^(1/2); I_R_pha_str1=atan2d(imag(I_R1),real(I_R1)); compass(I_R1,'Red'); v=strcat('I_R1 = ',num2str(I_R_mag_str1,'%10.2e'),' < ',num2str(I_R_pha_str1,'%4.2f'),' A'); set(handles.text56,'String',v); zoom on; zoom out hold on; I_Y_mag_str1=(real(I_Y1)^2+imag(I_Y1)^2)^(1/2); I_Y_pha_str1=atan2d(imag(I_Y1),real(I_Y1)); compass(I_Y1,'Yellow'); v=strcat('I_Y1 = ',num2str(I_Y_mag_str1,'%10.2e'),' < ',num2str(I_Y_pha_str1,'%4.2f'),' A'); set(handles.text57,'String',v); zoom on; zoom out hold on; I_B_mag_str1=(real(I_B1)^2+imag(I_B1)^2)^(1/2); I_B_pha_str1=atan2d(imag(I_B1),real(I_B1)); compass(I_B1,'Blue'); v=strcat('I_B1 = ',num2str(I_B_mag_str1,'%10.2e'),' < ',num2str(I_B_pha_str1,'%4.2f'),' A'); set(handles.text58,'String',v); zoom on; zoom out hold on; hold off; h4=handles.axes5; axes(handles.axes5); V_R_mag_str2=(real(V_R2)^2+imag(V_R2)^2)^(1/2); V_R_pha_str2=atan2d(imag(V_R2),real(V_R2)); compass(h4,V_R2,'Red'); v=strcat('V_R2 = ',num2str(V_R_mag_str2,'%10.2e'),' < ',num2str(V_R_pha_str2,'%4.2f'),' V'); set(handles.text59,'String',v); zoom on; zoom out hold on; V_Y_mag_str2=(real(V_Y2)^2+imag(V_Y2)^2)^(1/2); V_Y_pha_str2=atan2d(imag(V_Y2),real(V_Y2)); compass(V_Y2,'Yellow'); v=strcat('V_Y2 = ',num2str(V_Y_mag_str2,'%10.2e'),' < ',num2str(V_Y_pha_str2,'%4.2f'),' V'); set(handles.text60,'String',v); zoom on; zoom out hold on; V_B_mag_str2=(real(V_B2)^2+imag(V_B2)^2)^(1/2); V_B_pha_str2=atan2d(imag(V_B2),real(V_B2)); compass(V_B2,'Blue'); v=strcat('V_B2 = ',num2str(V_B_mag_str2,'%10.2e'),' < ',num2str(V_B_pha_str2,'%4.2f'),' V'); set(handles.text61,'String',v); zoom on; zoom out hold on; I_R_mag_str2=(real(I_R2)^2+imag(I_R2)^2)^(1/2); I_R_pha_str2=atan2d(imag(I_R2),real(I_R2)); compass(I_R2,'Red'); v=strcat('I_R2 = ',num2str(I_R_mag_str2,'%10.2e'),' < ',num2str(I_R_pha_str2,'%4.2f'),' A'); set(handles.text62,'String',v); zoom on; zoom out hold on; I_Y_mag_str2=(real(I_Y2)^2+imag(I_Y2)^2)^(1/2); I_Y_pha_str2=atan2d(imag(I_Y2),real(I_Y2)); compass(I_Y2,'Yellow'); v=strcat('I_Y2 = ',num2str(I_Y_mag_str2,'%10.2e'),' < ',num2str(I_Y_pha_str2,'%4.2f'),' A'); set(handles.text63,'String',v); zoom on; zoom out hold on; I_B_mag_str2=(real(I_B2)^2+imag(I_B2)^2)^(1/2); I_B_pha_str2=atan2d(imag(I_B2),real(I_B2)); compass(I_B2,'Blue'); v=strcat('I_B2 = ',num2str(I_B_mag_str2,'%10.2e'),' < ',num2str(I_B_pha_str2,'%4.2f'),' A'); set(handles.text64,'String',v); zoom on; zoom out hold on; hold off; h5=handles.axes2; t=0:0.0001:80e-3; vol_R=V_R_mag*sin(2*pi*50*t); vol_Y=V_Y_mag*sin(2*pi*50*t-240); vol_B=V_B_mag*sin(2*pi*50*t-120); cur_R=I_R_mag*sin(2*pi*50*t); cur_Y=I_Y_mag*sin(2*pi*50*t-240); cur_B=I_B_mag*sin(2*pi*50*t-120); axes(handles.axes2); plot(h5,t,vol_R,'Color','Red'); xlabel('time') ylabel('Magnitude') hold on; plot(t,vol_Y,'Color','Yellow'); hold on; plot(t,vol_B,'Color','Blue'); hold on; plot(t,cur_R,'color','Red'); xlabel('time') ylabel('Magnitude') hold on; plot(t,cur_Y,'color','Yellow'); hold on; plot(t,cur_B,'color','Blue'); grid on; hold off; V_R=r_V_R+i_V_R*j; V_Y=r_V_Y+i_V_Y*j; V_B=r_V_B+i_V_B*j; I_R=r_I_R+i_I_R*j; I_Y=r_I_Y+i_I_Y*j; I_B=r_I_B+i_I_B*j; %C=V_R*conj(I_R)+V_Y*conj(I_Y)+V_B*conj(I_B) C=[V_R V_Y V_B]*[I_R I_Y I_B]'; Q=imag(C); P=real(C); set(handles.edit13,'String',num2str(P)); set(handles.edit14,'String',num2str(Q)); set(handles.edit15,'String',num2str(C)); fid = fopen( 'Report.txt', 'wt' ); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Report on Symmetrical Components : Date: %s\n',date); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Input Parameters\n'); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Voltages:\n'); fprintf(fid,'V_R = %s < %s\n',num2str(V_R_mag),num2str(V_R_pha)); fprintf(fid,'V_Y = %s < %s\n',num2str(V_Y_mag),num2str(V_Y_pha)); fprintf(fid,'V_B = %s < %s\n',num2str(V_B_mag),num2str(V_B_pha)); fprintf(fid,'Currents:\n'); fprintf(fid,'I_R = %s < %s\n',num2str(I_R_mag),num2str(I_R_pha)); fprintf(fid,'I_Y = %s < %s\n',num2str(I_Y_mag),num2str(I_Y_pha)); fprintf(fid,'I_B = %s < %s\n',num2str(I_B_mag),num2str(I_B_pha)); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Output Parameters:\n Zero Symmetrical Components:\n'); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Voltages:\n'); fprintf(fid,'V_R0 = %s < %s V\n',num2str(V_R_mag_str0),num2str(V_R_pha_str0)); fprintf(fid,'V_Y0 = %s < %s V\n',num2str(V_Y_mag_str0),num2str(V_Y_pha_str0)); fprintf(fid,'V_B0 = %s < %s V\n',num2str(V_B_mag_str0),num2str(V_B_pha_str0)); fprintf(fid,'Currents:\n'); fprintf(fid,'I_R0 = %s < %s A\n',num2str(I_R_mag_str0),num2str(I_R_pha_str0)); fprintf(fid,'I_Y0 = %s < %s A\n',num2str(I_Y_mag_str0),num2str(I_Y_pha_str0)); fprintf(fid,'I_B0 = %s < %s A\n\n',num2str(I_B_mag_str0),num2str(I_B_pha_str0)); fprintf(fid,'Positive Symmetrical Components:\n'); fprintf(fid,'Voltages:\n'); fprintf(fid,'V_R1 = %s < %s V\n',num2str(V_R_mag_str1),num2str(V_R_pha_str1)); fprintf(fid,'V_Y1 = %s < %s V\n',num2str(V_Y_mag_str1),num2str(V_Y_pha_str1)); fprintf(fid,'V_B1 = %s < %s V\n',num2str(V_B_mag_str1),num2str(V_B_pha_str1)); fprintf(fid,'Currents:\n'); fprintf(fid,'I_R1 = %s < %s A\n',num2str(I_R_mag_str1),num2str(I_R_pha_str1)); fprintf(fid,'I_Y1 = %s < %s A\n',num2str(I_Y_mag_str1),num2str(I_Y_pha_str1)); fprintf(fid,'I_B1 = %s < %s A\n\n',num2str(I_B_mag_str1),num2str(I_B_pha_str1)); fprintf(fid,'Negative Symmetrical Components:\n'); fprintf(fid,'Voltages:\n'); fprintf(fid,'V_R2 = %s < %s V\n',num2str(V_R_mag_str2),num2str(V_R_pha_str2)); fprintf(fid,'V_Y2 = %s < %s V\n',num2str(V_Y_mag_str2),num2str(V_Y_pha_str2)); fprintf(fid,'V_B2 = %s < %s V\n',num2str(V_B_mag_str2),num2str(V_B_pha_str2)); fprintf(fid,'Currents:\n'); fprintf(fid,'I_R2 = %s < %s A\n',num2str(I_R_mag_str2),num2str(I_R_pha_str2)); fprintf(fid,'I_Y2 = %s < %s A\n',num2str(I_Y_mag_str2),num2str(I_Y_pha_str2)); fprintf(fid,'I_B2 = %s < %s A\n\n',num2str(I_B_mag_str2),num2str(I_B_pha_str2)); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fprintf(fid,'Active Power: %s Watts\n',num2str(P)); fprintf(fid,'Reactive Power: %s Var\n',num2str(Q)); fprintf(fid,'Complex Power: %s VA\n',num2str(C)); fprintf(fid,'---------------------------------------------------------------------------------------------- \n'); fclose(fid); display('Computations done'); function edit16_Callback(hObject, eventdata, handles) % hObject handle to edit16 (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 edit16 as text % str2double(get(hObject,'String')) returns contents of edit16 as a double % --- Executes during object creation, after setting all properties. function edit16_CreateFcn(hObject, eventdata, handles) % hObject handle to edit16 (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 edit17_Callback(hObject, eventdata, handles) % hObject handle to edit17 (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 edit17 as text % str2double(get(hObject,'String')) returns contents of edit17 as a double % --- Executes during object creation, after setting all properties. function edit17_CreateFcn(hObject, eventdata, handles) % hObject handle to edit17 (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 edit18_Callback(hObject, eventdata, handles) % hObject handle to edit18 (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 edit18 as text % str2double(get(hObject,'String')) returns contents of edit18 as a double % --- Executes during object creation, after setting all properties. function edit18_CreateFcn(hObject, eventdata, handles) % hObject handle to edit18 (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 edit19_Callback(hObject, eventdata, handles) % hObject handle to edit19 (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 edit19 as text % str2double(get(hObject,'String')) returns contents of edit19 as a double % --- Executes during object creation, after setting all properties. function edit19_CreateFcn(hObject, eventdata, handles) % hObject handle to edit19 (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 edit20_Callback(hObject, eventdata, handles) % hObject handle to edit20 (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 edit20 as text % str2double(get(hObject,'String')) returns contents of edit20 as a double % --- Executes during object creation, after setting all properties. function edit20_CreateFcn(hObject, eventdata, handles) % hObject handle to edit20 (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 edit21_Callback(hObject, eventdata, handles) % hObject handle to edit21 (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 edit21 as text % str2double(get(hObject,'String')) returns contents of edit21 as a double % --- Executes during object creation, after setting all properties. function edit21_CreateFcn(hObject, eventdata, handles) % hObject handle to edit21 (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 edit22_Callback(hObject, eventdata, handles) % hObject handle to edit22 (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 edit22 as text % str2double(get(hObject,'String')) returns contents of edit22 as a double % --- Executes during object creation, after setting all properties. function edit22_CreateFcn(hObject, eventdata, handles) % hObject handle to edit22 (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 edit23_Callback(hObject, eventdata, handles) % hObject handle to edit23 (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 edit23 as text % str2double(get(hObject,'String')) returns contents of edit23 as a double % --- Executes during object creation, after setting all properties. function edit23_CreateFcn(hObject, eventdata, handles) % hObject handle to edit23 (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 edit24_Callback(hObject, eventdata, handles) % hObject handle to edit24 (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 edit24 as text % str2double(get(hObject,'String')) returns contents of edit24 as a double % --- Executes during object creation, after setting all properties. function edit24_CreateFcn(hObject, eventdata, handles) % hObject handle to edit24 (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 edit25_Callback(hObject, eventdata, handles) % hObject handle to edit25 (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 edit25 as text % str2double(get(hObject,'String')) returns contents of edit25 as a double % --- Executes during object creation, after setting all properties. function edit25_CreateFcn(hObject, eventdata, handles) % hObject handle to edit25 (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 edit26_Callback(hObject, eventdata, handles) % hObject handle to edit26 (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 edit26 as text % str2double(get(hObject,'String')) returns contents of edit26 as a double % --- Executes during object creation, after setting all properties. function edit26_CreateFcn(hObject, eventdata, handles) % hObject handle to edit26 (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 edit27_Callback(hObject, eventdata, handles) % hObject handle to edit27 (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 edit27 as text % str2double(get(hObject,'String')) returns contents of edit27 as a double % --- Executes during object creation, after setting all properties. function edit27_CreateFcn(hObject, eventdata, handles) % hObject handle to edit27 (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 during object creation, after setting all properties. function figure1_CreateFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- 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) msgbox('Prof. Venkataswamy R, venkataswamy.r@gmail.com, venkat.gnanagenea.com www.gnanagenea.com','Author:','modal') % --- 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) global vol_R vol_Y vol_B; global t; figure(1); plot(t,vol_R,'Color','Red'); xlabel('time'); ylabel('Magnitude'); title('Voltage'); grid on; hold on; plot(t,vol_Y,'Color','Yellow'); hold on; plot(t,vol_B,'Color','Blue'); hold on; % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global cur_R cur_Y cur_B; global t; figure(1); plot(t,cur_R,'color','Red'); xlabel('time'); ylabel('Magnitude'); title('Currents'); grid on hold on; plot(t,cur_Y,'color','Yellow'); hold on; plot(t,cur_B,'color','Blue'); grid on; hold off; % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % global cur_R cur_Y cur_B; % global vol_R vol_Y vol_B; % global t; figure(1); % plot(t,cur_R.*vol_R,'color','Red'); % xlabel('time'); % ylabel('Magnitude'); % title('Currents'); % grid on % hold on; % plot(t,cur_Y.*vol_Y,'color','Yellow'); % hold on; % plot(t,cur_B.*vol_B,'color','Blue'); % grid on; % hold off; global C P Q; compass(C,'black') hold on; compass(P,'magenta') hold on; compass(Q,'cyan'); % --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) figure(1) global V_R0 V_Y0 V_B0; compass(V_R0) hold on; compass(V_Y0) hold on; compass(V_B0) zoom on; zoom out hold on; % --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) figure(1) global V_R1 V_Y1 V_B1; compass(V_R1,'Red') hold on; compass(V_Y1,'Yellow') hold on; compass(V_B1,'Blue') zoom on; zoom out hold on; % --- Executes on button press in pushbutton8. function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) figure(1) global V_R2 V_Y2 V_B2; compass(V_R2,'Red') hold on; compass(V_Y2,'Yellow') hold on; compass(V_B2,'Blue') zoom on; zoom out hold on; % --- Executes on button press in pushbutton9. function pushbutton9_Callback(hObject, eventdata, handles) % hObject handle to pushbutton9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global V_R0; report ReportTemplate.rpt display('Report generation done'); % --- Executes on button press in pushbutton10. function pushbutton10_Callback(hObject, eventdata, handles) % hObject handle to pushbutton10 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) dos('notepad Report.txt');