No BSD License  

Highlights from
GUI for the performance analysis of pedelecs

image thumbnail
from GUI for the performance analysis of pedelecs by Jan Cappelle
Modeling the behaviour of electric bicycles

Performance_Parameters(varargin)
function varargout = Performance_Parameters(varargin)
%PERFORMANCE_PARAMETERS M-file for Performance_Parameters.fig
%      PERFORMANCE_PARAMETERS, by itself, creates a new PERFORMANCE_PARAMETERS or raises the existing
%      singleton*.
%
%      H = PERFORMANCE_PARAMETERS returns the handle to a new PERFORMANCE_PARAMETERS or the handle to
%      the existing singleton*.
%
%      PERFORMANCE_PARAMETERS('Property','Value',...) creates a new PERFORMANCE_PARAMETERS using the
%      given property value pairs. Unrecognized properties are passed via
%      varargin to Performance_Parameters_OpeningFcn.  This calling syntax produces a
%      warning when there is an existing singleton*.
%
%      PERFORMANCE_PARAMETERS('CALLBACK') and PERFORMANCE_PARAMETERS('CALLBACK',hObject,...) call the
%      local function named CALLBACK in PERFORMANCE_PARAMETERS.M with the given input
%      arguments.
%
%      *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 Performance_Parameters

% Last Modified by GUIDE v2.5 10-May-2007 09:46:03

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Performance_Parameters_OpeningFcn, ...
                   'gui_OutputFcn',  @Performance_Parameters_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 Performance_Parameters is made visible.
function Performance_Parameters_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   unrecognized PropertyName/PropertyValue pairs from the
%            command line (see VARARGIN)

% Choose default command line output for Performance_Parameters
handles.output = hObject;



addpath(genpath(fullfile(matlabroot,'toolbox\LSSVM')));
addpath(genpath(fullfile(matlabroot,'toolbox\Pedelecs')));
addpath(genpath(fullfile(matlabroot,'toolbox\Pedelecs\drivecycles')));
addpath(genpath(fullfile(matlabroot,'toolbox\Pedelecs\drivecycles\@cycles')));

handles.folderput=0;
handles.DCfolderput=0;
handles.mtot=100;

%to check if the data for the boxplots are already available
handles.figeta=0;
handles.figksi=0;
handles.figSA=0;
handles.figDCeta=0;
handles.figDCksi=0;
handles.matname='data';
handles.UD=[];
handles.UI=[];


%right units 
handles.EnerUnit2=0;
handles.EnerUnit=0;

%battery initialization
handles.Vbat=12;
handles.CAP=7;
handles.DOD=80;
handles.etabm=90;

%handles.DCfolder='c:\';

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Performance_Parameters wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Performance_Parameters_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 eta_Callback(hObject, eventdata, handles)
% hObject    handle to eta (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 eta as text
%        str2double(get(hObject,'String')) returns contents of eta as a double


% --- Executes during object creation, after setting all properties.
function eta_CreateFcn(hObject, eventdata, handles)
% hObject    handle to eta (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 etaplot.
function etaplot_Callback(hObject, eventdata, handles)
% hObject    handle to etaplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.figeta==0
    errordlg('The distribution of the 100W efficiencies is not available, try to push the calculate-button','Bad Input','modal')
else
        figure(1)
        tit=('100W efficiency')
        boxplot(handles.etat,'label',tit)
        ylabel('\eta [%]','rotation',0)
        str={'boxplot of the 100W efficiencies of the '};
        title(strcat(str,handles.pedelec),'fontsize',12)
        axis([0.5 1.5 0 100])
end
guidata(hObject,handles);



function ksiMAe_Callback(hObject, eventdata, handles)
% hObject    handle to ksiMAe (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 ksiMAe as text
%        str2double(get(hObject,'String')) returns contents of ksiMAe as a double


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


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


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


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


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


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


% --- Executes during object creation, after setting all properties.
function SAMAp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SAMAp (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 SAplot.
function SAplot_Callback(hObject, eventdata, handles)
% hObject    handle to SAplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.figSA==0
   errordlg('The distribution of the 100W slope-ability is not available, try to push the calculate-button','Bad Input','modal')
elseif not(isnumeric(handles.mtot))
    errordlg('The total mass of pedelec rider and pedelec has to be filled in','Bad Input','modal')
else
SAt=[handles.SAZAt' handles.SAMAt];
names(1)={'ZA'};
for i=1:length(handles.name)
    names(i+1)=handles.name(i);
end
str1={'boxplot of the 100W slope-ability of the '};
str2={' with mass='}; 
str3={'kg'};
str=strcat(str1,handles.pedelec,str2,num2str(handles.mtot),str3);
handles.numberi
    if handles.numberi==4
        rs(1)=ranksum(SAt(:,1),SAt(:,2));
        rs(2)=ranksum(SAt(:,2),SAt(:,3));
        rs(3)=ranksum(SAt(:,3),SAt(:,4));
        figure(3)
        boxplot(SAt,'labels',names)
        axis([0.5 4.5 0 30])
        ylabel('Slope-ability [%]')
        title(str,'fontsize',12)
        text(1.3,24,num2str(rs(1),4))
        text(2.3,26,num2str(rs(2),4))
        text(3.3,24,num2str(rs(3),4))
        text(1,26,'Wilcoxon ZA-MAe')
        text(2,28,'Wilcoxon MAe-MAn')
        text(3,26,'Wilcoxon MAn-MAp')
    elseif handles.numberi==3
        rs(1)=ranksum(SAt(:,1),SAt(:,2));
        rs(2)=ranksum(SAt(:,2),SAt(:,3));
        figure(2)
        boxplot(SAt,'labels',names)
        axis([0.5 3.5 0 30])
        ylabel('Slope-ability [%]')
        title(str,'fontsize',12) 
        text(1.3,24,num2str(rs(1),4))
        text(2.3,24,num2str(rs(2),4))
        text(1.1,26,'Wilcoxon ZA-MA1')
        text(2.1,26,'Wilcoxon MA1-MA2')
    elseif handles.numberi==2
        rs(1)=ranksum(SAt(:,1),SAt(:,2));
        figure(2)
        boxplot(SAt,'labels',names)
        axis([0.5 2.5 0 30])
        ylabel('Slope-ability [%]')
        title(str,'fontsize',12) 
        text(1.3,24,num2str(rs(1),4))
        text(1.2,26,'Wilcoxon ZA-MAn')
    else
        figure(2)
        boxplot(SAt,'labels',names)
        axis([0.5 1.5 0 30])
        ylabel('Slope-ability [%]')
        title(str,'fontsize',12) 
    end
end
guidata(hObject,handles);


function DCfolder_Callback(hObject, eventdata, handles)
% hObject    handle to DCfolder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=get(hObject,'string');
set(handles.DCfolder,'string',a);
handles.DCfolderput=1;
guidata(hObject,handles);

% Hints: get(hObject,'String') returns contents of DCfolder as text
%        str2double(get(hObject,'String')) returns contents of DCfolder as a double


% --- Executes during object creation, after setting all properties.
function DCfolder_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DCfolder (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 Folder_Callback(hObject, eventdata, handles)
% hObject    handle to Folder (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 Folder as text
%        str2double(get(hObject,'String')) returns contents of Folder as a double
a=get(hObject,'string');
set(handles.Folder,'string',a);
handles.folderput=1;
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function Folder_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Folder (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 BrowseDCfolder.
function BrowseDCfolder_Callback(hObject, eventdata, handles)
% hObject    handle to BrowseDCfolder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
DirName = uigetdir('C:\','Select the directory where the drive cycle cycledata.mat file is stored');
handles.BrowseDCfolder=DirName;
set(handles.DCfolder,'string',DirName);
handles.DCfolderput=1;

guidata(hObject,handles);



% --- Executes on button press in BrowseFolder.
function BrowseFolder_Callback(hObject, eventdata, handles)
% hObject    handle to BrowseFolder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
DirName = uigetdir('C:\','Select the directory where the pedelec data.mat file is stored');
handles.folderput=1;
set(handles.Folder,'string',DirName);
guidata(hObject,handles);



% --- Executes on button press in CalculateUI.
function CalculateUI_Callback(hObject, eventdata, handles)
% hObject    handle to CalculateUI (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%first determine what models are available

%set all fields to ?
set(handles.eta,'string','?');
set(handles.ksiMAe,'string','?');
set(handles.ksiMAn,'string','?');
set(handles.ksiMAp,'string','?');
set(handles.SAZA,'string','?');
set(handles.SAMAe,'string','?');
set(handles.SAMAn,'string','?');
set(handles.SAMAp,'string','?');
if handles.folderput==0 %no given directory
         errordlg('There is no directory selected to look for the pedelec datafile','Bad Input','modal')
     avail=zeros(1,4);
elseif handles.folderput==1 %there is a directory given
    newpath=get(handles.Folder,'string');
    probfile=fullfile(newpath,'pedelec.mat');%look for the 'folder/pedelec.mat'
    avail=zeros(1,4);
    if exist(probfile)==0 %the dir has no pedelec.mat file
        errordlg('There was no pedelec.mat file found in the given directory','Bad Input','modal')
        avail=zeros(1,4);
    elseif exist(probfile)~=0 %the dir has a pedelec.mat file
        probdata=load(probfile); 
        if isfield(probdata,'vTcModels') %look for Ft(v,Tc) models and tell which of the 6 are available 
                %create a list with available models
                modellist=fieldnames(probdata.vTcModels);
                comparelist={'ZA','MAe','MAn','MAp'};
                for k=1:length(comparelist)
                    if sum(strcmp(modellist,comparelist(k)))~=0
                        avail(k)=1;
                    else
                        avail(k)=0;
                    end
                end
                handles.Z=str2double(probdata.pZ);%define the models
                handles.pedelec=probdata.pname(1);
        else avail=zeros(1,4);
            
        end
    end
end
i=1;
handles.numberi=1;
handles.ksit=[];
handles.SAMAt=[];
handles.name={};
if sum(avail)==0
     errordlg('There were no models found in the pedelec.mat file in the given directory','Bad Input','modal')
elseif avail(1)~=0 %calculate 100W efficiency
        modelETA=probdata.vTcModels.ETA;
        %store all the distribution in handles.vart
        handles.etat=100*constantwatt(modelETA,handles.Z,100,1); 
        
        gemY1a=mean(handles.etat);
        
        gemY1=num2str(gemY1a,2);%round to 2 digits
        set(handles.eta,'string',gemY1);
        modelZA=probdata.vTcModels.ZA;
        str=strcat(probdata.pname(1));
        handles.figeta=1;
        
        handles.UI.ETA.d=handles.etat;
        handles.UI.ETA.m=gemY1a;
        
        %calculate 100W slope-ability ZA
        handles.SAZAt=constantwattSA(modelZA,handles.Z,100,1,handles.mtot);
        gemY1b=mean(handles.SAZAt);
        gemY1=num2str(gemY1b,2);%round to 2 digits
        set(handles.SAZA,'string',gemY1);
        handles.figSA=1;
        
        handles.UI.SA.d.ZA=handles.SAZAt';
        handles.UI.SA.m.ZA=gemY1b;
        
    if avail(2)~=0 %calculate 75WMAe
        modelMAe=probdata.vTcModels.MAe;
        %store the distribution of the ksi's in handles.ksit
        handles.ksit(:,i)=constantwattksi(modelZA,modelMAe,handles.Z,75,1);
        gemY2a=mean(handles.ksit(:,i));
        gemY2=num2str(gemY2a,2);%round to 2 digits
        set(handles.ksiMAe,'string',gemY2);
        handles.name(i)={'MAe'};
        handles.figksi=1;
        
        handles.UI.XI.d.MAe=handles.ksit(:,i);
        handles.UI.XI.m.MAe=gemY2a;
        
        %calculate 100W slope abilitity MAe
        handles.SAMAt(:,i)=constantwattSA(modelMAe,handles.Z,100,1,handles.mtot);
        gemY2b=mean(handles.SAMAt(:,i));
        gemY2=num2str(gemY2b,2);%round to 2 digits
        set(handles.SAMAe,'string',gemY2);
        handles.figSA=1;
       
        
        handles.UI.SA.d.MAe=handles.SAMAt(:,i);
        handles.UI.SA.m.MAe=gemY2b;
         i=i+1;
        
    end    
    if avail(3)~=0 %calculate 75WMAn
        modelMAn=probdata.vTcModels.MAn;
        handles.ksit(:,i)=constantwattksi(modelZA,modelMAn,handles.Z,75,1);
        gemY3a=mean(handles.ksit(:,i));
        gemY3=num2str(gemY3a,2);
        set(handles.ksiMAn,'string',gemY3);
        handles.name(i)={'MAn'};
        handles.figksi=1;
       
        handles.UI.XI.d.MAn=handles.ksit(:,i);
        handles.UI.XI.m.MAn=gemY3a;
        
        %calculate 100W slope abilitity MAn
        handles.SAMAt(:,i)=constantwattSA(modelMAn,handles.Z,100,1,handles.mtot);
        gemY3b=mean(handles.SAMAt(:,i));
        gemY3=num2str(gemY3b,2);%round to 2 digits
        set(handles.SAMAn,'string',gemY3);
        handles.figSA=1;
      
        
        handles.UI.SA.d.MAn=handles.SAMAt(:,i);
        handles.UI.SA.m.MAn=gemY3b;
        i=i+1;
        
    end    
    if avail(4)~=0 %calculate 75WMAp
        modelMAp=probdata.vTcModels.MAp;
        handles.ksit(:,i)=constantwattksi(modelZA,modelMAp,handles.Z,75,1);
        gemY4a=mean(handles.ksit(:,i));
        gemY4=num2str(gemY4a,2);
        set(handles.ksiMAp,'string',gemY4);
        handles.name(i)={'MAp'};
        handles.figksi=1;
        
        handles.UI.XI.d.MAp=handles.ksit(:,i);
        handles.UI.XI.m.MAp=gemY4a;
                
        %calculate 100W slope abilitity MAp
        handles.SAMAt(:,i)=constantwattSA(modelMAp,handles.Z,100,1,handles.mtot);
        gemY4b=mean(handles.SAMAt(:,i));
        gemY4=num2str(gemY4b,2);%round to 2 digits
        set(handles.SAMAp,'string',gemY4);
        handles.figSA=1;
        
        handles.UI.SA.d.MAp=handles.SAMAt(:,i);
        handles.UI.SA.m.MAp=gemY4b;
        i=i+1;
    end 
    handles.numberi=i;
end

guidata(hObject,handles);

% --- Executes on button press in Save.
function Save_Callback(hObject, eventdata, handles)
% hObject    handle to Save (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
name=handles.matname;
UI=handles.UI;
UD=handles.UD;
dirk=cd;
[folder, name, ext, versn]=fileparts(get(handles.Folder,'string'));
cd(get(handles.Folder,'string'))
save(handles.matname,'UI','UD');
cd(dirk)
warndlg(['The cycledata.mat is stored in ', get(handles.Folder,'string')]);


% --- Executes on button press in ksiplot.
function ksiplot_Callback(hObject, eventdata, handles)
% hObject    handle to ksiplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.figksi==0
   errordlg('The distribution of the 75W assistance factors is not available, try to push the calculate-button','Bad Input','modal')
else
    if handles.numberi==4 %there are 3 assistance modes
        rs(1)=ranksum(handles.ksit(:,1),handles.ksit(:,2));
        rs(2)=ranksum(handles.ksit(:,2),handles.ksit(:,3));
        figure(2)
        boxplot(handles.ksit,'labels',handles.name)
        axis([0.5 3.5 0 1])
        ylabel('\xi','rotation',0)
        str=strcat({'boxplot of the 75W assistance factors of the '},handles.pedelec);
        title(str,'fontsize',12) 
        text(1.3,0.8,num2str(rs(1),4))
        text(2.3,0.8,num2str(rs(2),4))
        text(1.1,0.9,'Wilcoxon MAe-MAn')
        text(2.1,0.9,'Wilcoxon MAn-MAp')
    elseif handles.numberi==3
        rs(1)=ranksum(handles.ksit(:,1),handles.ksit(:,2));
        figure(2)
        boxplot(handles.ksit,'labels',handles.name)
        axis([0.5 2.5 0 1])
        ylabel('\xi','rotation',0)
        str=strcat({'boxplot of the 75W assistance factors of the '},handles.pedelec);
        title(str,'fontsize',12) 
        text(1.3,0.8,num2str(rs(1),4))
        text(1.2,0.9,'Wilcoxon')
    else        
    figure(2)
    size(handles.ksit)
    handles.name
    boxplot(handles.ksit,'labels',handles.name)
    axis([0.5 1.5 0 1])
    ylabel('\xi','rotation',0)
    str=strcat({'boxplot of the 75W assistance factors of the '},handles.pedelec);
    title(str,'fontsize',12) 
    end
end
guidata(hObject,handles);



function mtot_Callback(hObject, eventdata, handles)
% hObject    handle to mtot (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 mtot as text
%        str2double(get(hObject,'String')) returns contents of mtot as a double
m = str2double(get(hObject,'string'));
if isnan(m)
    errordlg('You must enter a numeric value','Bad Input','modal')
end
handles.mtot=m;
guidata(hObject,handles);

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


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


% --- Executes during object creation, after setting all properties.
function DCksiMAp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DCksiMAp (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 DCcalculate.
function DCcalculate_Callback(hObject, eventdata, handles)
% hObject    handle to DCcalculate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.folderput==0 %no given directory
     errordlg('There is no directory selected to look for the pedelec datafile','Bad Input','modal')
     avail=zeros(1,4);
elseif handles.folderput==1 %there is a directory given
    newpath=get(handles.Folder,'string');
    probfile=fullfile(newpath,'pedelec.mat');%look for the 'folder/pedelec.mat'
    avail=zeros(1,4);
    if exist(probfile)==0 %the dir has no pedelec.mat file
        errordlg('There was no pedelec.mat file found in the given directory','Bad Input','modal')
        avail=zeros(1,4);
    elseif exist(probfile)~=0 %the dir has a pedelec.mat file
        probdata=load(probfile); 
        if isfield(probdata,'vFtModels') %look for Ft(v,Tc) models and tell which of the 6 are available 
                %create a list with available models
                modellist=fieldnames(probdata.vFtModels);
                comparelist={'ZA','MAe','MAn','MAp'};
                for k=1:length(comparelist)
                    if sum(strcmp(modellist,comparelist(k)))~=0
                        avail(k)=1;
                    else
                        avail(k)=0;
                    end
                end
                handles.Z=str2double(probdata.pZ);%define the models
                handles.pedelec=probdata.pname(1);
        else
            avail=zeros(1,4);
        end
    end
end


if handles.DCfolderput==0 %no given directory
     errordlg('There is no directory selected to look for the drive cycle datafile','Bad Input','modal')
elseif handles.DCfolderput==1 %there is a directory given
    newpath=get(handles.DCfolder,'string');
    %newpath=handles.DCfolder;
    probfile=fullfile(newpath,'cycledata.mat');%look for the 'folder/data.mat'
    if exist(probfile)==0 %the dir has no data.mat file
        errordlg('There was no cycledata.mat file found in the given drive cycle folder','Bad Input','modal')
    elseif exist(probfile)~=0 %the dir has a data.mat file
        probcycledata=load(probfile); 
        Cycles=get(probcycledata.Cycleforces,'cycle');
        %Cycles=probcycledata.Cycleforces.cycle;
        Forces=probcycledata.Cycleforces;
        t=get(Cycles,'t');
        dt=get(Cycles,'dt');
        v1=get(Cycles,'v');
        %t=Cycles.t;
        %dt=Cycles.t;
        %v1=Cycles.v;
        Tcycle=(length(t)-1)*dt;
    end
end
set(handles.DCeta,'string','?');
set(handles.DCksiMAe,'string','?');
set(handles.DCksiMAn,'string','?');
set(handles.DCksiMAp,'string','?');
set(handles.WcZA,'string','?');
set(handles.WcMAe,'string','?');
set(handles.WcMAn,'string','?');
set(handles.WcMAp,'string','?');
set(handles.WtmMAe,'string','?');
set(handles.WtmMAn,'string','?');
set(handles.WtmMAp,'string','?');
set(handles.DcMAe,'string','?');
set(handles.DcMAn,'string','?');
set(handles.DcMAp,'string','?');
i=1;
handles.numberi=1;
handles.DCksiMAt=[];
handles.DCname={};
if sum(avail)==0
     errordlg('The model without assistance is required for these performance parameters','Bad Input','modal')
elseif avail(1)==1; %calculate the drive cycle efficiency
    modelZA=probdata.vFtModels.ZA;
    [Ptmin Ptmeas]=cyclewatt3(modelZA,Forces,handles.Z);
    etat=Ptmin./Ptmeas;
    handles.DCetat=100*etat;
    eta1=100*mean(Ptmin)/mean(Ptmeas);
    eta=num2str(eta1,2);
    
    handles.UD.ETA.m=eta1;
    handles.UD.ETA.d=handles.DCetat;
    
    set(handles.DCeta,'string',eta);
    %calculate the drive cycle human energy ZA
    WcZA=mean(Ptmeas)*Tcycle;
    handles.UD.HEI.ZA=WcZA;
    
    WcZAJ=num2str(WcZA,5);
    WcZAWh=num2str(WcZA/3600,3);
        if handles.EnerUnit==1
           set(handles.WcZA,'string',WcZAJ);
        else
           set(handles.WcZA,'string',WcZAWh);
        end
    handles.figDCeta=1;
    if avail(2)==1;
        %calculate the drive cycle human energy MAe
        modelMAe=probdata.vFtModels.MAe;
        [PtZA PtMAe]=cyclewattksi(modelZA,modelMAe,Forces,handles.Z);
        WcZA=mean(PtZA)*Tcycle;
        WcMAe=mean(PtMAe)*Tcycle;
        
        WcMAeJ=num2str(WcMAe,5);
        WcMAeWh=num2str(WcMAe/3600,3);
        if handles.EnerUnit==1
            set(handles.WcMAe,'string',WcMAeJ);
        else
            set(handles.WcMAe,'string',WcMAeWh);
        end
        %calculate the net motor energy MAe
        WtmMAe=WcZA-WcMAe;
        WtmMAeJ=num2str(WtmMAe,5);
        WtmMAeWh=num2str(WtmMAe/3600,3);
        if handles.EnerUnit2==1
            set(handles.WtmMAe,'string',WtmMAeJ);
        else
            set(handles.WtmMAe,'string',WtmMAeWh);
        end
        %calculate the assistance factor MAe
        DCksiMAe=WtmMAe/WcZA;
        set(handles.DCksiMAe,'string',num2str(DCksiMAe,2));
        DCbatMAe=DCbatradius(modelZA,modelMAe,handles.Z,Forces,handles.Vbat,handles.CAP,handles.DOD/100,handles.etabm/100);
        
        
        
        set(handles.DcMAe,'string',num2str(DCbatMAe,2));
        n=1;
            for k=1:length(PtZA) % filter out the powers less than 2 watt!!!
                if PtZA(k)>2
                    PtmotorMAe(n)=PtZA(k)-PtMAe(k);
                    PtZAf(n)=PtZA(k);
                    n=n+1;
                end
            end
        DCksiMAt(:,i)=PtmotorMAe./PtZAf;
        handles.DCname(i)={'MAe'};
        handles.figDCksi=1;
        
        handles.UD.HEI.MAe=WcMAe;
        handles.UD.XI.m.MAe=DCksiMAe;
        handles.UD.BR.MAe=DCbatMAe;
        handles.UD.XI.d.MAe=DCksiMAt(:,i);
        
        i=i+1;
    end
    if avail(3)==1;
        %calculate the drive cycle human energy MAn
        modelMAn=probdata.vFtModels.MAn;
        [PtZA PtMAn]=cyclewattksi(modelZA,modelMAn,Forces,handles.Z);
        WcZA=mean(PtZA)*Tcycle;
        WcMAn=mean(PtMAn)*Tcycle;
        WcMAnJ=num2str(WcMAn,5);
        WcMAnWh=num2str(WcMAn/3600,3);
        if handles.EnerUnit==1
            set(handles.WcMAn,'string',WcMAnJ);
        else
            set(handles.WcMAn,'string',WcMAnWh);
        end
        %calculate the net motor energy MAn
        WtmMAn=WcZA-WcMAn;
        WtmMAnJ=num2str(WtmMAn,5);
        WtmMAnWh=num2str(WtmMAn/3600,3);
        if handles.EnerUnit2==1
            set(handles.WtmMAn,'string',WtmMAnJ);
        else
            set(handles.WtmMAn,'string',WtmMAnWh);
        end
        %calculate the assistance factor MAn
        DCksiMAn=WtmMAn/WcZA;
        set(handles.DCksiMAn,'string',num2str(DCksiMAn,2));
        DCbatMAn=DCbatradius(modelZA,modelMAn,handles.Z,Forces,handles.Vbat,handles.CAP,handles.DOD/100,handles.etabm/100);
        set(handles.DcMAn,'string',num2str(DCbatMAn,2));
        n=1;
            for k=1:length(PtZA) % filter out the powers less than 2 watt!!!
                if PtZA(k)>2
                    PtmotorMAn(n)=PtZA(k)-PtMAn(k);
                    PtZAf(n)=PtZA(k);
                    n=n+1;
                end
            end
        DCksiMAt(:,i)=PtmotorMAn./PtZAf;
        handles.DCname(i)={'MAn'};
        handles.figDCksi=1;
        
        handles.UD.HEI.MAn=WcMAn;
        handles.UD.XI.m.MAn=DCksiMAn;
        handles.UD.BR.MAn=DCbatMAn;
        handles.UD.XI.d.MAn=DCksiMAt(:,i);
        
        i=i+1;
    end
    if avail(4)==1;
        %calculate the drive cycle human energy MAn
        modelMAp=probdata.vFtModels.MAp;
        [PtZA PtMAp]=cyclewattksi(modelZA,modelMAp,Forces,handles.Z);
        WcZA=mean(PtZA)*Tcycle;
        WcMAp=mean(PtMAp)*Tcycle;
        WcMApJ=num2str(WcMAp,5);
        WcMApWh=num2str(WcMAp/3600,3);
        if handles.EnerUnit==1
            set(handles.WcMAp,'string',WcMApJ);
        else
            set(handles.WcMAp,'string',WcMApWh);
        end
        %calculate the motor propulsion energy MAp
        WpmMAp=WcZA-WcMAp;
        WpmMApJ=num2str(WpmMAp,5);
        WpmMApWh=num2str(WpmMAp/3600,3);
        if handles.EnerUnit2==1
            set(handles.WtmMAp,'string',WpmMApJ);
        else
            set(handles.WtmMAp,'string',WpmMApWh);
        end
        %calculate the assistance factor MAp
        DCksiMAp=WpmMAp/WcZA;
        set(handles.DCksiMAp,'string',num2str(DCksiMAp,2));
        DCbatMAp=DCbatradius(modelZA,modelMAp,handles.Z,Forces,handles.Vbat,handles.CAP,handles.DOD/100,handles.etabm/100);
        set(handles.DcMAp,'string',num2str(DCbatMAp,2));
        n=1;
            for k=1:length(PtZA) % filter out the powers less than 2 watt!!!
                if PtZA(k)>2
                    PtmotorMAp(n)=PtZA(k)-PtMAp(k);
                    PtZAf(n)=PtZA(k);
                    n=n+1;
                end
            end
        DCksiMAt(:,i)=PtmotorMAp./PtZAf;
        handles.DCname(i)={'MAp'};
        handles.figDCksi=1;
        
        handles.UD.HEI.MAp=WcMAp;
        handles.UD.XI.m.MAp=DCksiMAp;
        handles.UD.BR.MAp=DCbatMAp;
        handles.UD.XI.d.MAp=DCksiMAt(:,i);
        
        i=i+1;
    end
    handles.DCksiMAt=DCksiMAt;
    handles.numberDCi=i;
end
guidata(hObject,handles);




% --- Executes on button press in DCetaplot.
function DCetaplot_Callback(hObject, eventdata, handles)
% hObject    handle to DCetaplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.figDCeta==0
    errordlg('The distribution of the drive cycle efficiencies is not available, try to push the calculate-button','Bad Input','modal')
else
figure(4)
tit=('Drive cycle efficiency')
boxplot(handles.DCetat,'label',tit)
ylabel('\eta [%]','rotation',0)
str={'boxplot of the drive cycle efficiencies of the '};
title(strcat(str,handles.pedelec),'fontsize',12)
axis([0.5 1.5 0 100])
end
guidata(hObject,handles);


function DCksiMAe_Callback(hObject, eventdata, handles)
% hObject    handle to DCksiMAe (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 DCksiMAe as text
%        str2double(get(hObject,'String')) returns contents of DCksiMAe as a double


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


% --- Executes during object creation, after setting all properties.
function DCksiMAn_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DCksiMAn (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 DCksiplot.
function DCksiplot_Callback(hObject, eventdata, handles)
% hObject    handle to DCksiplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if handles.figDCksi==0
   errordlg('The distribution of the 75W assistance factors is not available, try to push the calculate-button','Bad Input','modal')
else
    str=strcat({'boxplot of the drive cycle assistance factors of the '},handles.pedelec);
    if handles.numberDCi==4 %there are 3 assistance modes
        rs(1)=ranksum(handles.DCksiMAt(:,1),handles.DCksiMAt(:,2));
        rs(2)=ranksum(handles.DCksiMAt(:,2),handles.DCksiMAt(:,3));
        figure(5)
        boxplot(handles.DCksiMAt,'labels',handles.DCname)
        axis([0.5 3.5 0 1])
        ylabel('\xi','rotation',0)
        title(str,'fontsize',12) 
        text(1.3,0.8,num2str(rs(1),4))
        text(2.3,0.8,num2str(rs(2),4))
        text(1.1,0.9,'Wilcoxon MAe-MAn')
        text(2.1,0.9,'Wilcoxon MAn-MAp')
    elseif handles.numberDCi==3
        rs(1)=ranksum(handles.DCksiMAt(:,1),handles.DCksiMAt(:,2));
        figure(5)
        boxplot(handles.DCksiMAt,'labels',handles.DCname)
        axis([0.5 2.5 0 1])
        ylabel('\xi','rotation',0)
        title(str,'fontsize',12) 
        text(1.3,0.8,num2str(rs(1),4))
        text(1.2,0.9,'Wilcoxon')
    else  
        figure(5)
        boxplot(handles.DCksiMAt,'labels',handles.DCname)
        ylabel('\xi','rotation',0)
        title(str,'fontsize',12)
        axis([0.5 1.5 0 1])
    end
end
guidata(hObject,handles);

% --- Executes on button press in DCsave.
function DCsave_Callback(hObject, eventdata, handles)
% hObject    handle to DCsave (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDE)
name=handles.matname;
UI=handles.UI;
UD=handles.UD;
dirk=cd;
[folder, name, ext, versn]=fileparts(get(handles.Folder,'string'));
cd(get(handles.Folder,'string'))
save(handles.matname,'UI','UD');
cd(dirk)
warndlg(['The cycledata.mat is stored in ', get(handles.Folder,'string')]);


function WcMAe_Callback(hObject, eventdata, handles)
% hObject    handle to WcMAe (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 WcMAe as text
%        str2double(get(hObject,'String')) returns contents of WcMAe as a double


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


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


% --- Executes during object creation, after setting all properties.
function WcMAp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WcMAp (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 Wcplot.
function Wcplot_Callback(hObject, eventdata, handles)
% hObject    handle to Wcplot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function WcZA_Callback(hObject, eventdata, handles)
% hObject    handle to WcZA (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 WcZA as text
%        str2double(get(hObject,'String')) returns contents of WcZA as a double


% --- Executes during object creation, after setting all properties.
function WcZA_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WcZA (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 selection change in EnerUnit.
function EnerUnit_Callback(hObject, eventdata, handles)
% hObject    handle to EnerUnit (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 EnerUnit contents as cell array
%        contents{get(hObject,'Value')} returns selected item from EnerUnit
val = get(hObject,'Value');
switch val
case 1
    handles.EnerUnit=0;
case 2
    handles.EnerUnit=1;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function EnerUnit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EnerUnit (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



function WtmMAe_Callback(hObject, eventdata, handles)
% hObject    handle to WtmMAe (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 WtmMAe as text
%        str2double(get(hObject,'String')) returns contents of WtmMAe as a double


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


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


% --- Executes during object creation, after setting all properties.
function WtmMAp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WtmMAp (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 Wtmplot.
function Wtmplot_Callback(hObject, eventdata, handles)
% hObject    handle to Wtmplot (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 EnerUnit2.
function EnerUnit2_Callback(hObject, eventdata, handles)
% hObject    handle to EnerUnit2 (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 EnerUnit2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from EnerUnit2
val = get(hObject,'Value');
switch val
case 1
    handles.EnerUnit2=0;
case 2
    handles.EnerUnit2=1;
end
guidata(hObject, handles);


% --- Executes during object creation, after setting all properties.
function EnerUnit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to EnerUnit2 (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



function DcMAe_Callback(hObject, eventdata, handles)
% hObject    handle to DcMAe (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 DcMAe as text
%        str2double(get(hObject,'String')) returns contents of DcMAe as a double


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


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


% --- Executes during object creation, after setting all properties.
function DcMAp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DcMAp (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 Vbat_Callback(hObject, eventdata, handles)
% hObject    handle to Vbat (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 Vbat as text
%        str2double(get(hObject,'String')) returns contents of Vbat as a double
m = str2double(get(hObject,'string'));
if isnan(m)
    errordlg('You must enter a numeric value','Bad Input','modal')
end
handles.Vbat=m;
guidata(hObject,handles);



% --- Executes during object creation, after setting all properties.
function Vbat_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Vbat (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 CAP_Callback(hObject, eventdata, handles)
% hObject    handle to CAP (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 CAP as text
%        str2double(get(hObject,'String')) returns contents of CAP as a double
m = str2double(get(hObject,'string'));
if isnan(m)
    errordlg('You must enter a numeric value','Bad Input','modal')
end
handles.CAP=m;
guidata(hObject,handles);



% --- Executes during object creation, after setting all properties.
function CAP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to CAP (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 DOD_Callback(hObject, eventdata, handles)
% hObject    handle to DOD (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 DOD as text
%        str2double(get(hObject,'String')) returns contents of DOD as a double
m = str2double(get(hObject,'string'));
if isnan(m)
    errordlg('You must enter a numeric value','Bad Input','modal')
end
handles.DOD=m;
guidata(hObject,handles);



% --- Executes during object creation, after setting all properties.
function DOD_CreateFcn(hObject, eventdata, handles)
% hObject    handle to DOD (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 etabm_Callback(hObject, eventdata, handles)
% hObject    handle to etaoverall (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 etaoverall as text
%        str2double(get(hObject,'String')) returns contents of etaoverall as a double
m = str2double(get(hObject,'string'));
if isnan(m)
    errordlg('You must enter a numeric value','Bad Input','modal')
end
handles.etabm=m;
guidata(hObject,handles);



% --- Executes during object creation, after setting all properties.
function etabm_CreateFcn(hObject, eventdata, handles)
% hObject    handle to etaoverall (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 matname_Callback(hObject, eventdata, handles)
% hObject    handle to matname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.matname=get(hObject,'String');
guidata(hObject,handles);

% Hints: get(hObject,'String') returns contents of matname as text
%        str2double(get(hObject,'String')) returns contents of matname as a double


% --- Executes during object creation, after setting all properties.
function matname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to matname (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


Contact us at files@mathworks.com