Example: Function call: meanabs_risk_nd_g(matrix_7,matrix_11_s).
matrix_7:
x1 |
x2 |
x3 |
x4 |
scenario_benchmark |
1 |
4 |
8 |
3 |
-2 |
matrix_11_s:
x1 |
x2 |
x3 |
x4 |
scenario_benchmark |
8.93784 -0.25271 -1.27649 -0.77983 -0.3662 |
-0.25271 9.64713 -1.60709 -0.15443 3.7164 |
-1.27649 -1.60709 4.91926 -2.73949 -0.4274 |
-0.77983 -0.15443 -2.73949 7.44517 -0.39033 |
-0.3662 3.7164 -0.4274 -0.39033 9.26 |
at point_1:
component_name |
value |
x1 x2 x3 x4 |
1 1 1 1 |
MATLAB code (.\Aorda\PSG\MATLAB\Examples\Func_value_meanabs_risk_nd_g.m) for function calculation:
%Define data:
H1 = [1 4 8 3];
header_1 = {'x1', 'x2', 'x3', 'x4'};
c1 = -2;
H2 = [8.93784 -0.25271 -1.27649 -0.77983;-0.25271 9.64713 -1.60709 -0.15443;-1.27649 -1.60709 4.91926 -2.73949;-0.77983 -0.15443 -2.73949 7.44517;-0.3662 3.7164 -0.4274 -0.39033];
header_2 = {'x1', 'x2', 'x3', 'x4'};
c2 = [-0.3662;3.7164;-0.4274;-0.39033;9.26];
a = [1;1;1;1];
%=======================================================================
%Calculation of function with PSG Subroutine 'functionvalue'
%Calculate meanabs_risk_nd_g function at point 'a':
val1 = functionvalue('meanabs_risk_nd_g', [], {H1 ,H2}, {c1 ,c2}, {[] ,[]}, a);
%Display function value:
disp(sprintf('functionvalue = %g', val1));
%=======================================================================
%Calculation of function with PSG Subroutine 'tbpsg_function_value'
%Create the PSG matrix 'matrix_1'(structure containing header and matrix body) and pack it to structure 'toolboxstruc_arr':
toolboxstruc_arr(1) = tbpsg_matrix_pack('matrix_1', H1, [], c1, []);
%Create the PSG matrix 'matrix_2'(structure containing header and matrix body) and pack it to structure 'toolboxstruc_arr':
toolboxstruc_arr(2) = tbpsg_matrix_pack('matrix_2', H2, [], c2, []);
%Create the PSG point 'point_1'(structure containing header and matrix body) and pack it to structure 'toolboxstruc_arr':
toolboxstruc_arr(3) = tbpsg_point_pack('point_1', a, []);
%Calculate meanabs_risk_nd_g function at point 'point_1':
val2 = tbpsg_function_value('meanabs_risk_nd_g(matrix_1,matrix_2)','point_1',toolboxstruc_arr);
%Display function value:
disp(sprintf('tbpsg_function_value = %g', val2));
%=======================================================================
%Creation of User Subroutine for calculating function value
%User subroutine is similar to the 'functionvalue'
%Create problem statement:
problem_statement = sprintf('%s\n',...
'calculate',...
'Point: point_1',...
' meanabs_risk_nd_g(matrix_1,matrix_2)',...
' ');
%Create Subroutine:
tbpsg_create_user_subroutine(problem_statement,toolboxstruc_arr,'.\','calculate_meanabs_risk_nd_g');
%Uncomment section to call the user subroutine 'calculate_meanabs_risk_nd_g':
%{
%Calculation of function with User Subroutine 'calculate_meanabs_risk_nd_g':
[solution_str,outargstruc_arr] = calculate_meanabs_risk_nd_g(H1,matrix_1_vars,c1,H2,matrix_2_vars,c2,a,point_1_vars);
%Extract function value from the solution report:
val = tbpsg_function_data(solution_str, outargstruc_arr);
%}
Program output:
functionvalue = 21.7017
tbpsg_function_value = 21.7017