Sie sind auf Seite 1von 8

PROGRAM

function varargout = ManBac(varargin)


% MANBAC MATLAB code for ManBac.fig
% MANBAC, by itself, creates a new MANBAC or raises the existing
% singleton*.
%
% H = MANBAC returns the handle to a new MANBAC or the handle to
% the existing singleton*.
%
% MANBAC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MANBAC.M with the given input arguments.
%
% MANBAC('Property','Value',...) creates a new MANBAC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ManBac_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ManBac_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 ManBac

% Last Modified by GUIDE v2.5 03-Oct-2018 06:01:34

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ManBac_OpeningFcn, ...
'gui_OutputFcn', @ManBac_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 ManBac is made visible.


function ManBac_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 ManBac (see VARARGIN)
imshow('51x.JPG')
% Choose default command line output for ManBac
handles.output = hObject;

% create an axes that spans the whole gui


ah = axes('unit', 'normalized', 'position', [0 0 1 1]);
% import the background image and show it on the axes
bg = imread('background.jpg'); imagesc(bg);
% prevent plotting over the background and turn the axis off
set(ah,'handlevisibility','off','visible','off')
% making sure the background is behind all the other uicontrols
uistack(ah, 'bottom');

% Update handles structure


guidata(hObject, handles);

% UIWAIT makes ManBac wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = ManBac_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 button press in Solve.


function Solve_Callback(hObject, eventdata, handles)
% hObject handle to Solve (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

V = str2double(get(handles.voltage,'string'));
A = str2double(get(handles.Angle,'string'));
R1 = str2double(get(handles.resistor1,'string'));
R2 = str2double(get(handles.resistor2,'string'));
R3 = str2double(get(handles.resistor3,'string'));
L = str2double(get(handles.inductor,'string'));
C = str2double(get(handles.capacitor,'string'));
N1 = str2double(get(handles.n1,'string'));
N2 = str2double(get(handles.n2,'string'));
N3 = str2double(get(handles.n3,'string'));
N4 = str2double(get(handles.n4,'string'));

%solving reflected impedance


Zr1 = (R3+L)/(N4/N3)^2;
Zr2 = [(R2+Zr1)/(N2/N1)^2];
Zin = R1+C+Zr2;
Zinca = real(Zin);
Zincb = imag(Zin);

%Solving for I1
Vs = V*exp(i*A*pi/180);
I1 = Vs/Zin;
Iai = abs(I1);
Ibi = angle(I1)*180/pi;

%Solving for Complex Power


S = Vs*conj(I1);
Sr = real(S);
Si = imag(S);

set(handles.current1,'string',Iai);
set(handles.current2,'string',Ibi);
set(handles.zin1,'string',Zinca);
set(handles.zin2,'string',Zincb);
set(handles.complex1,'string',Sr);
set(handles.complex2,'string',Si);

function voltage_Callback(hObject, eventdata, handles)


% hObject handle to voltage (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 voltage as text


% str2double(get(hObject,'String')) returns contents of voltage as a
double

% --- Executes during object creation, after setting all properties.


function voltage_CreateFcn(hObject, eventdata, handles)
% hObject handle to voltage (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 resistor1_Callback(hObject, eventdata, handles)


% hObject handle to resistor1 (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 resistor1 as text


% str2double(get(hObject,'String')) returns contents of resistor1 as a
double

% --- Executes during object creation, after setting all properties.


function resistor1_CreateFcn(hObject, eventdata, handles)
% hObject handle to resistor1 (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 capacitor_Callback(hObject, eventdata, handles)


% hObject handle to capacitor (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 capacitor as text


% str2double(get(hObject,'String')) returns contents of capacitor as a
double

% --- Executes during object creation, after setting all properties.


function capacitor_CreateFcn(hObject, eventdata, handles)
% hObject handle to capacitor (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 resistor2_Callback(hObject, eventdata, handles)


% hObject handle to resistor2 (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 resistor2 as text


% str2double(get(hObject,'String')) returns contents of resistor2 as a
double

% --- Executes during object creation, after setting all properties.


function resistor2_CreateFcn(hObject, eventdata, handles)
% hObject handle to resistor2 (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 resistor3_Callback(hObject, eventdata, handles)


% hObject handle to resistor3 (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 resistor3 as text


% str2double(get(hObject,'String')) returns contents of resistor3 as a
double

% --- Executes during object creation, after setting all properties.


function resistor3_CreateFcn(hObject, eventdata, handles)
% hObject handle to resistor3 (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 inductor_Callback(hObject, eventdata, handles)


% hObject handle to inductor (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 inductor as text


% str2double(get(hObject,'String')) returns contents of inductor as a
double
% --- Executes during object creation, after setting all properties.
function inductor_CreateFcn(hObject, eventdata, handles)
% hObject handle to inductor (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 n2_Callback(hObject, eventdata, handles)


% hObject handle to n2 (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 n2 as text


% str2double(get(hObject,'String')) returns contents of n2 as a double

% --- Executes during object creation, after setting all properties.


function n2_CreateFcn(hObject, eventdata, handles)
% hObject handle to n2 (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 n4_Callback(hObject, eventdata, handles)


% hObject handle to n4 (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 n4 as text


% str2double(get(hObject,'String')) returns contents of n4 as a double

% --- Executes during object creation, after setting all properties.


function n4_CreateFcn(hObject, eventdata, handles)
% hObject handle to n4 (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 Angle_Callback(hObject, eventdata, handles)


% hObject handle to Angle (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 Angle as text


% str2double(get(hObject,'String')) returns contents of Angle as a
double

% --- Executes during object creation, after setting all properties.


function Angle_CreateFcn(hObject, eventdata, handles)
% hObject handle to Angle (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 n1_Callback(hObject, eventdata, handles)


% hObject handle to n1 (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 n1 as text


% str2double(get(hObject,'String')) returns contents of n1 as a double

% --- Executes during object creation, after setting all properties.


function n1_CreateFcn(hObject, eventdata, handles)
% hObject handle to n1 (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 n3_Callback(hObject, eventdata, handles)


% hObject handle to n3 (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 n3 as text


% str2double(get(hObject,'String')) returns contents of n3 as a double

% --- Executes during object creation, after setting all properties.


function n3_CreateFcn(hObject, eventdata, handles)
% hObject handle to n3 (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

Das könnte Ihnen auch gefallen