tbpsg_matrix_pack function packs data to PSG Matrix in MATLAB.
Syntax
[this_struct] = tbpsg_matrix_pack(name, data)
[this_struct] = tbpsg_matrix_pack(name, data, vars)
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark)
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark, probability)
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark, probability, options)
Description
[this_struct] = tbpsg_matrix_pack(name, data) returns (packs) structure this_struct with PSG Matrix in Toolbox format (see PSG Matrix in Toolbox). Names of variables (vars), by default are 'x1', … , 'x#n', where n is the number of columns in matrix data.
[this_struct] = tbpsg_matrix_pack(name, data, vars) packs matrix with names of variables vars.
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark) packs matrix with benchmark.
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark, probability) packs matrix with probability.
[this_struct] = tbpsg_matrix_pack(name, data, vars, benchmark, probability, options) packs matrix with additional options.
Input Arguments
name |
name of matrix; |
data |
matrix data; |
vars |
names of variables; |
benchmark |
scenario benchmark data; |
probability |
probabilities of scenarios; |
options |
structure with field overwrite. If input (data, vars, benchmark,or probability) of tbpsg_matrix_pack is MATLAB expression (not MATLAB variable), then the new variable with name matrix_name_keyword (name = input of tbpsg_matrix_pack, keyword = data, vars, bench,or prob) will be created. If variable matrix_name_keyword already exists and options.overwrite = 1 (default), then this variable will be overwritten. Otherwise, a new variable with name matrix_name_keyword_i (i = 1,2,...) will be created. |
Remarks
• | name of matrix should not exceed 128 symbols, it is not case sensitive and should includes only alphabetic characters, numbers, and underscore sign, “_”. |
Output Arguments
this_struct |
pointer to the PSG data structure. |
Example
Here is the matrix of scenarios for an example problem:
b1 |
b2 |
scenario_probability |
scenario_benchmark |
-1 |
0 |
0.1 |
0 |
0 |
0 |
0.9 |
0 |
To pack this matrix to the structure "toolboxstruc_arr" write:
vars = {'b1', 'b2'};
matrix = [-1 0; 0 0];
benchmark = [0 0];
probability = [0.1 0.9];
toolboxstruc_arr = tbpsg_matrix_pack('matrix_scenarios', matrix, vars, benchmark, probability);
Output:
>> toolboxstruc_arr
toolboxstruc_arr =
type: 'matrix'
data: [1x1 struct]
string: [1x1 struct]
>> toolboxstruc_arr.data
ans =
name: 'scenarios'
data: [2x2 double]
vars: 'b1 b2'
bench: [2x1 double]
prob: [2x1 double]
>> toolboxstruc_arr.data.data
ans =
-1 0
0 0
>> toolboxstruc_arr.string
ans =
name: 'scenarios'
data: 'matrix'
vars: 'vars'
bench: 'benchmark'
prob: 'probability'
See also
PSG Matrix in Toolbox, tbpsg_pmatrix_pack, tbpsg_vector_pack, tbpsg_point_pack, tbpsg_parameter_pack