Scilab-Branch-6.1-GIT
- Ajuda do Scilab
- API Scilab
- legacy
- API Scilab
- API types
- Getting started with API_Scilab
- API double functions
- API common functions
- API string functions
- API boolean functions
- API integer functions
- API list-type functions
- API polynomial functions
- API pointer functions
- API cell functions
- API struct functions
- API handle functions
- API optional functions
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
API cell functions
This page lists all the functions to manipulate Cell objects.
scilabVar
scilab_createCellMatrix
(
scilabEnv
env, int dim, const int* dims)
Create a cell matrix with dim
dimensions (dims
[0], dims
[1], ..., dims
[dim
-1]).
scilabVar
scilab_createCellMatrix2d
(
scilabEnv
env, int row, int col)
Create a cell matrix with 2 dimensions (row
, col
).
scilabStatus
scilab_getCellValue
(
scilabEnv
env,
scilabVar
var, int* index,
scilabVar
*val)
Get data at position (index
[0], index
[1], ..., index
[dims-1]) from var
.
scilabStatus
scilab_getCell2dValue
(
scilabEnv
env,
scilabVar
var, int row, int col,
scilabVar
*val)
Get data at position (row
, col
) from var
.
scilabStatus
scilab_setCellValue
(
scilabEnv
env,
scilabVar
var, int* index,
scilabVar
val)
Set data at position (index
[0], index
[1], ..., index
[dims-1]) in var
.
scilabStatus
scilab_setCell2dValue
(
scilabEnv
env,
scilabVar
var, int row, int col,
scilabVar
val)
Set data at position (row
, col
) in var
.
Examples
#include <ctype.h> #include "api_scilab.h" #include "Scierror.h" #include "localization.h" #include "sciprint.h" #include "sci_malloc.h" #include "os_string.h" const char fname[] = "cell_test"; int sci_cell_test(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt opt, int nout, scilabVar* out) { int i = 0; //input int size1 = 0; scilabVar in1 = NULL; double* dims = NULL; scilabVar in2 = NULL; int size2 = 0; //output int outSize = 1; scilabVar out1 = NULL; scilabVar* vars = NULL; if (nin != 2) { Scierror(999, _("%s: Wrong number of input arguments: %d expected.\n"), fname, 2); return STATUS_ERROR; } if (nout != 1) { Scierror(999, _("%s: Wrong number of output arguments: %d expected.\n"), fname, 1); return STATUS_ERROR; } //in1 in1 = in[0]; if (scilab_isDouble(env, in1) == 0 || scilab_getSize(env, in1) != 2) { Scierror(999, _("%s: Wrong type for input argument #%d: double vector of size 2 expected.\n"), fname, 1); return STATUS_ERROR; } size1 = scilab_getSize(env, in1); scilab_getDoubleArray(env, in1, &dims); outSize = (int)dims[0] * (int)dims[1]; //in2 in2 = in[1]; if (scilab_isList(env, in2) == 0) { Scierror(999, _("%s: Wrong type for input argument #%d: A list expected.\n"), fname, 2); return STATUS_ERROR; } size2 = scilab_getSize(env, in2); if (outSize != size2) { Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 2); return STATUS_ERROR; } out1 = scilab_createCellMatrix2d(env, (int)dims[0], (int)dims[1]); for (i = 0; i < outSize; ++i) { scilab_setCell2dValue(env, out1, i, 0, scilab_getListItem(env, in2, i)); } out[0] = out1; return STATUS_OK; }
Scilab test script
mkdir(pathconvert(TMPDIR+"/api_c/")); cd(pathconvert(TMPDIR+"/api_c/")); copyfile(SCI+"/modules/api_scilab/tests/unit_tests/api_c/cell_test.c",pathconvert(TMPDIR+"/api_c/cell_test.c",%F)); ilib_build("libcell",["cell_test","sci_cell_test", "csci6"],"cell_test.c",[],"","",""); exec("loader.sce"); data = list(1, "2", %t, %s, list(1,2,3), {1,2;3,4}); c = cell_test([2 3], data); assert_checkequal(typeof(c), "ce"); assert_checkequal(c{1, 1}, 1); assert_checkequal(c{2, 1}, "2"); assert_checkequal(c{1, 2}, %t); assert_checkequal(c{2, 2}, %s); assert_checkequal(c{1, 3}, list(1,2,3)); assert_checkequal(c{2, 3}, {1,2;3,4});
Report an issue | ||
<< API pointer functions | API Scilab | API struct functions >> |