Code covered by the BSD License  

Highlights from
Supply Chain Risk Simulator (SCRS)

from Supply Chain Risk Simulator (SCRS) by Marco Anisetti
Supply Chain simulator for risk assessment and incentive schemes.

SCRS(varargin)
% Supply Chain Risk Simulator (SCRS)
% Copyright (C) 2009  Marco Anisetti Fulvio Frati
% Universita' degli Studi di Milano - Italy
% *************************************************************************
% Shapley value of cooperative game package (coalition.m shap1.m)
% Copyright (c) 2008, Saloman Danaraj
% All rights reserved.
% 
% Redistribution and use in source and binary forms, with or without 
% modification, are permitted provided that the following conditions are 
% met:
% 
%     * Redistributions of source code must retain the above copyright 
%       notice, this list of conditions and the following disclaimer.
%     * Redistributions in binary form must reproduce the above copyright 
%       notice, this list of conditions and the following disclaimer in 
%       the documentation and/or other materials provided with the distribution
%     * Neither the name of the Jubail Industrial college nor the names 
%       of its contributors may be used to endorse or promote products derived 
%       from this software without specific prior written permission.
%       
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
% POSSIBILITY OF SUCH DAMAGE.
% *******************************************************************************
%
% The Bezier related code presented in this project uses the matlab functions of
% "Yet another Bezier curve demo" by Xenya Petrova available in matlab
% central. 
% 
%*************************************************************************
%
% This code is related to the research article presented at the IEEE SITIS 2009
% Conference:
% "Supply Chain Risk Analysis:  Open Source Simulator" by  Marco Anisetti, 
% Valerio Bellandi, Ernesto Damiani, Fulvio Frati, and Gabriele Gianini, 
% (Dipartimento di Tecnologie dellInformazione, Universit degli studi di
% Milano Crema (CR) - Italy) Gwanggil Jeon and Jechang Jeong (Department
% of Electronics and Computer Engineering, Hanyang University).
% and related to the research article presented at the The International
% ACM Conference on Management of Emergent Digital EcoSystems (MEDES 2010)
%``Using Incentive Schemes to Alleviate Supply Chain Risks'',by M.
% Anisetti, S.Cimato, E. Damiani, F.Frati, G. Gianini, 
% 

%*************************************************************************
%TO-DO
% - refactoring of the code.
% - integration with e3value native file



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

% Last Modified by GUIDE v2.5 17-Jun-2010 17:00:41

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SCRS_OpeningFcn, ...
                   'gui_OutputFcn',  @SCRS_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 SCRS is made visible.
function SCRS_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 SCRS (see VARARGIN)

%Results structure

Res.PayOff=[];
Res.Economicalimpact=[];
Res.PayoffScenario=[];
Res.risk=[];
Res.scenario=[];
Res.ShapleyValues=[];
Res.Probability=[];
Res.Impact=[];
Res.Replaceability=[];

Res.PayOffI=[];
Res.ShapleyValuesI=[];
Res.ProbabilityI=[];
Res.ImpactI=[];
Res.riskI=[];
Res.LostIncentive=[];
Res.MonteIncentives=[];
Res.SimulatedAttack=[];

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

handles.rounds=varargin{1};
handles.type=varargin{2};
handles.incent=varargin{3};
handles.epoch=varargin{4};
handles.test=varargin{5};
handles.SupplyChain=varargin{6};
handles.funzione=varargin{7};
handles.File=varargin{8};

if (handles.incent==0)
 set(handles.uipanel10,'Visible','off'); 
end

% Update handles structure
guidata(hObject, handles);
%set(handles.buttonstart,'Enable','off');
% UIWAIT makes SCRS wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = SCRS_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 buttonstart.
function buttonstart_Callback(hObject, eventdata, handles)
% hObject    handle to buttonstart (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% loading supply chain parameters for each actors in the chain
% the SuppliersNew.mat contains also the relation between suppliers

if isfield(handles, 'SupplyChain')
    % rdf loaded
      SuppliersNew=handles.SupplyChain;
      disp ('Use the value model .rdf file')
else
    %load the default mat file
    load('SuppliersNew.mat');
    disp ('Use the default mat Chain specification')
end

%SuppliersNew(1) is the Master plan
% get some parameters
% set demand as prod cap of the master plennersuppier
SuppliersNew(1).Demand=str2num(get(handles.edit1,'String'));
SuppliersNew(1).ProdCap=SuppliersNew(1).Demand;
Demand=SuppliersNew(1).Demand;

VenditaMercato=SuppliersNew(1).UnitProdCost;

TimeToMarket=str2num(get(handles.edit3,'String'));

GlobalContext=get(handles.listbox2,'Value');
% Compute the Dry run chain allocation
disp('Compute the Dry run chain allocation');
memoryless=(2-handles.type);
%############### multiple rounds################
%Variables for debug and output
Results_risk_no_inc=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_risk_inc=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_prob_no_inc=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_prob_inc=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_impa=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_Ince=zeros(handles.rounds,length(SuppliersNew),handles.epoch);
Results_attack=zeros(handles.rounds,length(SuppliersNew),handles.epoch);

explore_perc=str2num(get(handles.edit5,'String'));
%############### Simulation cicle #################
for epoch=1:1:handles.epoch
    if epoch>1
       SuppliersNew=SuppliersOriginal;
    end   
for rounds=1:1:handles.rounds
    [x_ottimale,exitflag,fval_ottimale] = Simplex_SCRS(SuppliersNew,TimeToMarket,VenditaMercato);
if not(exitflag==1)
    disp('error computing simplex')
    return
end    

for i=1:1:length(SuppliersNew)
    SuppliersNew(i).Demand=x_ottimale(i);
end    
if ((epoch==1)&&(rounds==1))
   % Save the initial situation
   SuppliersOriginal=SuppliersNew;
   fval_iniziale=fval_ottimale;
   GuadagnoAlPezzo=(-fval_ottimale/SuppliersNew(1).Demand);
end   
% Shapley for every Suppliers in the chain
disp('Shapley Computation');
% Comment the following line if you want to compute shapley only on the
% selected chian's actors after the optimization.
ActiveSuppliers=1:length(SuppliersNew);
%########################### SHAPLEY ######################################
% In this version the shapley is considered independent on market variation
ShapleyDelta_Computation;
%####################### ATTACK Payoff ####################################
% is set if a particular attack target is required (i.e. = to 100 is 100 euros is the attack target)
% -1 if not used
% not implemented yet
ValueTarget=-1;
AttacksPayoff_Computation;
%generate or load conditional probability table for conditional probability
%computation
Conditional_ProbabilityTable;
%##########################################################################
ShapleyValues=ShapleyDelta;
%####################### Replaceability ###################################
disp('Internal context: Replaceability')
Replaceability_Computation;
%####################### Probability ######################################
disp('Probability Computation');
[probability,contextstr]=Probability_Computation(ShapleyValues,PayOff,Replaceability,get(handles.radiobutton1,'Value'),GlobalContext);
% compute conditional probability in multiround
Conditional_Probability_Computation; 
%####################### Risk analysis ####################################
disp('Risk Landscape Computation')
risk=probability.*impact;
Results_risk_no_inc(rounds,:,epoch)=risk;
Results_prob_no_inc(rounds,:,epoch)=probability;
if strcmp(scenario, 'Lead Time')
    PayoffScenario(:,2:(length(SuppliersNew)+1))=int16(PayoffScenario(:,2:(length(SuppliersNew)+1)));
else
    PayoffScenario=int16(PayoffScenario);
end   
indice=(handles.rounds*(epoch-1))+rounds;
Res(indice).PayOff=fixdec(PayOff,2).*100;
Res(indice).Economicalimpact=-Economicalimpact;
Res(indice).PayoffScenario=PayoffScenario(:,1:(length(SuppliersNew)+1));
Res(indice).risk=fixdec(risk*100,2);
Res(indice).scenario=scenario;
Res(indice).ShapleyValues=fixdec(ShapleyValues*100,2);
Res(indice).Probability=fixdec(probability,3);
Res(indice).Impact=fixdec(impact*100,2);
Res(indice).Replaceability=fixdec(Replaceability*100,2);
Res(indice).SuppliersNew=SuppliersNew;
%######################## INCENTIVES ######################################
LostIncentive=zeros(size(PayOff));
if (handles.incent==1)
    disp('Incentives');
    Incentive_Computation;
    Res(indice).PayOffI=fixdec(PayOffI,2).*100;
    Res(indice).ShapleyValuesI=fixdec(ShapleyDeltaI*100,2);
    Res(indice).ProbabilityI=fixdec(probabilityI,3);
    Res(indice).ImpactI=fixdec(impactI*100,2);
    Res(indice).riskI=fixdec(riskI*100,2);
    Res(indice).LostIncentive=LostIncentive;
    Res(indice).MonteIncentives=MonteIncentives;
end

%#######################Simulated ATTACKS##########################
% for each epoch different attacks may take places
disp('Simulate scenarios')
%Conditional_ProbabilityTable
decision=handles.test(rounds,:,epoch);
probability_old=probability;
Simulated_attack=find(decision<probability);
Simulated_nonAttacker=find(decision>=probability);
Results_attack(rounds,:,epoch)=decision<probability; 
Res(indice).SimulatedAttack=decision<probability;
% the attacks take places and the outcome is the initialization for the
% next iteration.
if get(handles.radiobutton8,'Value')
   Results_Ince(rounds,:,epoch)=(LostIncentive);
else
   Results_Ince(rounds,:,epoch)=zeros(size(LostIncentive));
   Results_Ince(rounds,(Simulated_nonAttacker),epoch)=(LostIncentive(Simulated_nonAttacker)); 
end 
Results_impa(rounds,:,epoch)=zeros(size(Economicalimpact));
Results_impa(rounds,(Simulated_attack),epoch)=(Economicalimpact(Simulated_attack)); 
undelivered=zeros(1,length(SuppliersNew));

for i=1:1:length(Simulated_attack)
    disp('Attacker:')
    SuppliersNew(Simulated_attack(i)).Name
    disp('Parameter variation')
    prevfield=getfield(SuppliersNew(Simulated_attack(i)),attfield);
    [getfield(SuppliersNew(Simulated_attack(i)),attfield),PayoffScenario(Simulated_attack(i),1)]
%     if ~isfield(SuppliersNew(Simulated_attack(i)),att)
%         att=strcat(attfield,'Real');
%         eval(strcat(strcat('SuppliersNew(Simulated_attack(i))',att),'=[]');
%         setfield(SuppliersNew(Simulated_attack(i)),att,PayoffScenario(Simulated_attack(i),1));
%     end    
    SuppliersNew(Simulated_attack(i))=setfield(SuppliersNew(Simulated_attack(i)),attfield,PayoffScenario(Simulated_attack(i),1));
    if get(handles.radiobutton3,'Value')
        costreal=getfield(SuppliersNew(Simulated_attack(i)),'UnitProdCost');
        SuppliersNew(Simulated_attack(i))=setfield(SuppliersNew(Simulated_attack(i)),'UnitProdCost',costfake(Simulated_attack(i)));
    end
    % not delivery products
    undelivered(Simulated_attack(i))=aggiuntivo(Simulated_attack(i))/GuadagnoAlPezzo;
    if (undelivered(Simulated_attack(i))<0)
        disp('caso raro')
    end    
    if (~(memoryless))
       SuppliersNew(Simulated_attack(i)).ProdCap=SuppliersNew(Simulated_attack(i)).ProdCap-(undelivered(Simulated_attack(i)));
       if (get(handles.radiobutton3,'Value'))
          SuppliersNew(Simulated_attack(i)).UnitProdCost=costreal;
       %else
           %if (get(handles.radiobutton5,'Value')&&(undelivered>0))
           %   SuppliersNew(Simulated_attack(i)).UnitProdCost=prevfield;
           %end
       end    
    end   
end
% the current parameters are the initialization for the next round
disp('Next round')
rounds
x_prec=x_ottimale;
end
disp('Next Test')
epoch
end

ResultsExplorer(Res,handles.rounds,handles.epoch,handles.incent,Results_risk_no_inc,Results_risk_inc,Results_prob_no_inc,Results_prob_inc,Results_impa,Results_Ince,Results_attack);



% --- 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)
% Salva
GlobalContext=get(handles.listbox2,'Value');
if get(handles.radiobutton1,'Value')
    disp('Save Fuzzy')
else
    disp('Save Bezier')
    d=handles.dcurve;
    c=handles.ccurve;
    if (GlobalContext==1)
        save('payoff1','d')
        save('shapley1','c')
    else if (GlobalContext==2)
            save('payoff2','d')
            save('shapley2','c')
        else
            save('payoff3','d')
            save('shapley3','c')
        end    
    end    
end
set(handles.pushbutton3,'Enable','off');
% --- 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)
%Edit delle cureve o del Fuzzy
GlobalContext=get(handles.listbox2,'Value');
set(handles.listbox2,'Enable','off');

if get(handles.radiobutton1,'Value')
    %fuzzy('ProbabilityH-B-b4');
    %fuzzy('ProbabilityH-B-b4-Replace');
    if (GlobalContext==1)
        fuzzy('ProbabilityH-B-b4-Replace');
    else
        if (GlobalContext==2)
            fuzzy('ProbabilityH-B-b4-Replace_recession');
        else
            fuzzy('ProbabilityH-B-b4-Replace_growth');
        end
   end    
else
    if (GlobalContext==1)
        load('shapley1.mat') %c
        load('payoff1.mat') %d
    else
        if (GlobalContext==2)
            load('shapley2.mat') %c
            load('payoff2.mat') %d
        else
            load('shapley3.mat') %c
            load('payoff3.mat') %d
        end
    end    
    handles.ccurve=edit_curve(c,1);
    handles.dcurve=edit_curve(d,2);
end  
set(handles.pushbutton3,'Enable','on');
set(handles.listbox2,'Enable','on');
guidata(hObject, handles);




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




% --- 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)

disp('Not implemented in this version')



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




% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (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 listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton3
set(handles.radiobutton4,'Value',0);
set(handles.radiobutton5,'Value',0);
set(handles.radiobutton6,'Value',0);
%set(handles.radiobutton7,'Value',0);

% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton4
set(handles.radiobutton3,'Value',0);
set(handles.radiobutton5,'Value',0);
set(handles.radiobutton6,'Value',0);
%set(handles.radiobutton7,'Value',0);


% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton5
set(handles.radiobutton3,'Value',0);
set(handles.radiobutton4,'Value',0);
set(handles.radiobutton6,'Value',0);
%set(handles.radiobutton7,'Value',0);

% --- Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton6
set(handles.radiobutton3,'Value',0);
set(handles.radiobutton4,'Value',0);
set(handles.radiobutton5,'Value',0);
%set(handles.radiobutton7,'Value',0);

% --- Executes on button press in radiobutton7.
function radiobutton7_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.radiobutton3,'Value',0);
set(handles.radiobutton4,'Value',0);
set(handles.radiobutton5,'Value',0);
set(handles.radiobutton6,'Value',0);
% Hint: get(hObject,'Value') returns toggle state of radiobutton7





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


% --- Executes on button press in radiobutton8.
function radiobutton8_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.radiobutton9,'Value',0);

% Hint: get(hObject,'Value') returns toggle state of radiobutton8


% --- Executes on button press in radiobutton9.
function radiobutton9_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.radiobutton8,'Value',0);

% Hint: get(hObject,'Value') returns toggle state of radiobutton9


% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox1





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


% --- 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)
GlobalContext=get(handles.listbox2,'Value');
set(handles.listbox2,'Enable','off');
load('react_default.mat') %c
handles.react_curve=edit_curve(react,3);
guidata(hObject, handles);


% --- 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)
react=handles.react_curve;
save('react_default','react');




% --- Executes on button press in radiobutton11.
function radiobutton11_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton11
set(handles.radiobutton12,'Value',0);

% --- Executes on button press in radiobutton12.
function radiobutton12_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton12
set(handles.radiobutton11,'Value',0);



% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject    handle to checkbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of checkbox2


Contact us at files@mathworks.com