matlab mxarray array,[Matlab]MxArray与MwArray使用区别

引子

在外部编程语言与matlab的交互中,Array是最单元的交互元素,怎么都绕不过去。

在matlab提供的Array接口有两个,一个是C的MxArray, 另一个是Cpp(C++)的MwArray.

看下两着的分别介绍:

mxArray:Matlab C 函数库的结构体

mwArray:Matlab C++ 函数库中对mxArray的包装类

声明:

mxArray:mxArray *a;

mwArray:mwArray a;

销毁

mxArray:mxDestroyArray a;

mwArray:mwArray类的析构函数自动销毁对象

变量传递

mxArray:mxArray *dest_ptr =mxCreateDoubleMatrix(rows,cols, mxREAL);

memcpy(dest_ptr,source_ptr,MAX_SIZE);

mwArray:mwArray in1(rows, cols, mxDOUBLE_CLASS, mxREAL);

mwArray in2(rows, cols, mxDOUBLE_CLASS, mxREAL);

in1.SetData(data, rows*cols);

in2.SetData(data, rows*cols);

比较而言, 1。mwArray的声明更简洁,不用考虑指针 2。mwArray不用手动释放内存

mxArray 介绍

mxArray *mxCreateDoubleMatrix(int m, int n, mxComplexity ComplexFlag);

参数m和n为矩阵的函数和列数。ComplexFlag为常数,用来区分矩阵中元素是实数还是复数,取值分别为mxREAL和mxCOMPLEX。

类似的创建函数还有:

mxArray *mxCreateString(const char *str); 创建一个字符串类型并初始化为str字符串。

对应的,要删除一个数组mxDestroyArray,该函数声明如下:

void mxDestroyArray(mxArray *array_ptr);

要获得mxArray数组每一维上元素的个数,可以用mxGetM和mxGetN函数。其中mxGetM用来获得数组第一维的元素个数,对于矩阵来说就是行数。

int mxGetM(const mxArray *array_ptr); //返回array_ptr对应数组第一维的元素个数(行数)

int mxGetN(const mxArray *array_ptr); //返回array_ptr对应数组其它维的元素个数,对于矩阵来说是列数。对于多维数组来说是从第2维到最后一维的各维元素个数的乘积。

要获得某一特定维的元素个数,则要用函数:

const int *mxGetDimensions(const mxArray *array_ptr);

该函数返回array_ptr各维的元素个数保存在一个int数组中返回。对于常用的矩阵来说,用mxGetM和mxGetN两个函数就可以了。

另外还可以通过mxGetNumberOfDimensions来获得数组的总的维数,用mxSetM、mxSetN设置矩阵的行数和列数,函数说明如下:

int mxGetNumberOfDimensions(const mxArray *array_ptr); //返回数组的维数

void mxSetM(mxArray *array_ptr, int m); //设置数组为m行

void mxSetN(mxArray *array_ptr, int n); //设置数组为n列

在对mxArray类型的变量进行操作之前,可以验证以下其中的数组的数据类型,比如是否为double数组、整数、字符串、逻辑值等,以及是否为某种结构、类、或者是特殊类型,比如是否为空数组,是否为inf、NaN等。常见的判断函数有:

Use these functions to validate input arguments.

C Functions

mxIsDouble

Determine whether mxArray represents data as double-precision, floating-point numbers

mxIsSingle

Determine whether array represents data as single-precision, floating-point numbers

mxIsComplex

Determine whether data is complex

mxIsNumeric

Determine whether array is numeric

mxIsInt64

Determine whether array represents data as signed 64-bit integers

mxIsUint64

Determine whether array represents data as unsigned 64-bit integers

mxIsInt32

Determine whether array represents data as signed 32-bit integers

mxIsUint32

Determine whether array represents data as unsigned 32-bit integers

mxIsInt16

Determine whether array represents data as signed 16-bit integers

mxIsUint16

Determine whether array represents data as unsigned 16-bit integers

mxIsInt8

Determine whether array represents data as signed 8-bit integers

mxIsUint8

Determine whether array represents data as unsigned 8-bit integers

mxIsScalar

Determine whether array is scalar array

mxIsChar

Determine whether input is mxChar array

mxIsLogical

Determine whether array is of type mxLogical

mxIsLogicalScalar

Determine whether scalar array is of type mxLogical

mxIsLogicalScalarTrue

Determine whether scalar array of type mxLogical is true

mxIsStruct

Determine whether input is structure array

mxIsCell

Determine whether input is cell array

mxIsClass

Determine whether array is member of specified class

mxIsInf

Determine whether input is infinite

mxIsFinite

Determine whether input is finite

mxIsNaN

Determine whether input is NaN (Not-a-Number)

mxIsEmpty

Determine whether array is empty

mxIsSparse

Determine whether input is sparse array

mxIsFromGlobalWS

Determine whether array was copied from MATLAB global workspace

mxAssert

Check assertion value for debugging purposes

mxAssertS

Check assertion value without printing assertion text

对于常用的double类型的数组,可以用mxGetPr和mxGetPi两个函数分别获得其实部和虚部的数据指针,这两个函数的声明如下:

double *mxGetPr(const mxArray *array_ptr); //返回数组array_ptr的实部指针

double *mxGetPi(const mxArray *array_ptr); //返回数组array_ptr的虚部指针

Utilities for manipulating strings and structures.

C Functions

mxArrayToString

Array to string

mxArrayToUTF8String

Array to string in UTF-8 encoding

mxGetString

mxChar array to C-style string or Fortran character array

另外一种操作mxArray的方法(在mathworks上居然没有搜索到..... 囧)

//为了调用matlab中的函数,必须使用数组数据类型,并其后调用matlab函数将其转化为矩阵格式(matlab的基本数据类型是矩阵)

static double x1[1]={1.0};

static double x2[1]={2.5};

double result;

//调用matlab创建3个矩阵

mxArray *A=mclGetUninitializedArray();

mxArray *B=mclGetUninitializedArray();

mxArray *C=mclGetUninitializedArray();

//将C语言中的变量值赋给matlab中的矩阵

mlfAssign(&A,mlfDoubleMatrix(1,1,x1,NULL));

mlfAssign(&B,mlfDoubleMatrix(1,1,x2,NULL));

mlfAssign(&C,mlfMyfunct(A,B)); //调m函数

//将matlab中的矩阵的指针传递给C语言中的指向double的指针

double * md=mxGetPr(C);

result=md[0];

//释放这些矩阵

mxDestroyArray(A);

mxDestroyArray(B);

mxDestroyArray(C);

C++ Utility Classes

mwArray

Class used to pass input/output arguments to C functions generated by MATLAB Compiler SDK

mwException

Exception type used by the mwArray API and the C++ interface functions

mwString

String class used by the mwArray API to pass string data as output from certain methods

mwArray 介绍

构造函数Constructors

mwArray() Description 创建空的Matlab阵列,类型为mxDOUBLE_CLASS

mwArray(mxClassID mxID) Description 创建mxID指定类型的Matlab阵列

Arguments

mxClassID mxID

Valid mxClassID specifying the type of array to construct. See the Work with mxArrays for more information on mxClassID.

mwArray(mwSize num_rows, mwSize num_cols, mxClassID mxID, mxComplexity cmplx = mxREAL)

Description 创建行数为num_rows,列数为num_cols,类型为mxID的Matalb阵列,对于数值型阵列,将complx做为最后一个参数,确定待创建阵列是否为复数阵列

Arguments

mwSize num_rows

Number of rows in the array

mwSize num_cols

Number of columns in the array

mxClassID mxID

Valid mxClassID specifying the type of array to construct. See the Work with mxArrays for more information on mxClassID.

mxComplexity cmplx

Complexity of the array to create. Valid values are mxREAL and mxCOMPLEX. The default value is mxREAL.

mwArray(mwSize num_dims, const mwSize* dims, mxClassID mxID, mxComplexity cmplx = mxREAL)

Description

创建任意维数的Matlab阵列,维数由num_dims指定,各维大小由dims指定,mxID指定阵列的类型。对于数值型阵列,将cmplx作为最后的一个参数,确定待创建阵列是否为复型的阵列。

All elements are initialized to zero. For cell arrays, all elements are initialized to empty cells.

Arguments

mwSize num_dims

Number of dimensions in the array

const mwSize* dims

Dimensions of the array

mxClassID mxID

Valid mxClassID specifying the type of array to construct. See the Work with mxArrays for more information on mxClassID.

mxComplexity cmplx

Complexity of the array to create. Valid values are mxREAL and mxCOMPLEX. The default value is mxREAL.

mwArray(const char* str)

Description

Create a 1-by-n array of type mxCHAR_CLASS, with n = strlen(str), and initialize the array's data with the characters in the supplied string.

根据字符串str创建一个新的字符型阵列

Arguments

const char* str

Null-terminated character buffer used to initialize the array

mwArray(mwSize num_strings, const char** str)

Description

创建字符型阵列(mxCHAR_CLASS),字符串由str指定. The created array has dimensions m-by-max, where max is the length of the longest string in str.

Arguments

mwSize num_strings

Number of strings in the input array

const char** str

Array of null-terminated strings

mwArray(mwSize num_rows, mwSize num_cols, int num_fields, const char** fieldnames)

Description

Create a matrix of type mxSTRUCT_CLASS, with the specified field names. All elements are initialized with empty cells.

创建行数为num_rows,列数为num_cols结构体阵列(mxSTRUCT_CLASS), 结构体域名为由fieldnames指定,域名个数由num_fields指定

Arguments

mwSize num_rows

Number of rows in the array

mwSize num_cols

Number of columns in the array

int num_fields

Number of fields in the struct matrix.

const char** fieldnames

Array of null-terminated strings representing the field names

mwArray(mwSize num_dims, const mwSize* dims, int num_fields, const char** fieldnames)

Description

Create an n-dimensional array of type mxSTRUCT_CLASS, with the specified field names. All elements are initialized with empty cells.

创建任意维数的结构体阵列,维数由num_dims指定,各维大小由dims指定,结构体域名由fieldnames指定,域名个数由num_fields指定.

Arguments

mwSize num_dims

Number of dimensions in the array

const mwSize* dims

Dimensions of the array

int num_fields

Number of fields in the struct matrix.

const char** fieldnames

Array of null-terminated strings representing the field names

mwArray(const mwArray& arr)

Description

Create a deep copy of an existing array. 根据当前的阵列arr中创建一个新的阵列(复制)

Arguments

mwArray& arr

mwArray to copy

mwArray( re)

Description

Create a real scalar array. 创建一个新的数值阵列,实部为re.

The scalar array is created with the type of the input argument.

Arguments

re

Scalar value to initialize the array. can be any of the following:

mxDoublemxSinglemxInt8mxUint8mxInt16mxUint16

mxInt32mxUint32mxInt64mxUint64mxLogical

mwArray( re, im)

Description

Create a complex scalar array. 创建一个新的数值阵列,实部为re,虚部为im

The scalar array is created with the type of the input argument.

Arguments

re

Scalar value to initialize the real part of the array

im

Scalar value to initialize the imaginary part of the array

can be any of the following: mxDoublemxSinglemxInt8mxUint8mxInt16mxUint16mxInt32mxUint32mxInt64mxUint64mxLogical

Methods

mwArray Clone() const

Description

Create a new array representing deep copy of array.

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mwArray b = a.Clone();

mwArray SharedCopy() const

Description

Create a shared copy of an existing array. The new array and the original array both point to the same data.

返回一个新的共享数据型mwArray阵列,此阵列与现有的mwArray阵列指向同一个数据块。

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mwArray b = a.SharedCopy();

mwArray Serialize() const

Description

Serialize an array into bytes. A 1-by-n numeric matrix of type mxUINT8_CLASS is returned containing the serialized data. The data can be deserialized back into the original representation by calling mwArray::Deserialize().

将mwArray序列化一个新的阵列,新的阵列为mxUINT8_CLASS类型

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mwArray b = a.Serialize();

mxClassID ClassID() const

Description

Determine the type of the array. See the Work with mxArrays for more information on mxClassID.

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mxClassID id = a.ClassID();

int ElementSize() const

Description

Determine the size, in bytes, of an element of array type.

返回mwArray阵列元素大小

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int size = a.ElementSize();

size_t ElementSize() const

Description

Determine the size, in bytes, of an element of array type.

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int size = a.ElementSize();

mwSize NumberOfElements() const

Description

Determine the total size of the array.

返回阵列中元素的个数

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int n = a.NumberOfElements();

mwSize NumberOfNonZeros() const

Description

Determine the size of the of the array's data. If the underlying array is not sparse, this returns the same value as NumberOfElements().

返回稀疏阵列非零元素的个数

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int n = a.NumberOfNonZeros();

mwSize MaximumNonZeros() const

Description

Determine the allocated size of the of the array's data. If the underlying array is not sparse, this returns the same value as NumberOfElements().

返回稀疏阵列中最大的元素的个数

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int n = a.MaximumNonZeros();

mwSize NumberOfDimensions() const

Description

Determine the dimensionality of the array. 返回阵列维数

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

int n = a.NumberOfDimensions();

int NumberOfFields() const

Description

Determine the number of fields in a struct array. If the underlying array is not of type struct, zero is returned.

返回结构体域个数

Example

const char* fields[] = {"a", "b", "c"};

mwArray a(2, 2, 3, fields);

int n = a.NumberOfFields();

mwString GetFieldName(int index)

Description

Determine the name of a given field in a struct array. If the underlying array is not of type struct, an exception is thrown.

Arguments

int index

Index of the field to name. Indexing starts at zero.

Example

const char* fields[] = {"a", "b", "c"};

mwArray a(2, 2, 3, fields);

mwString tempname = a.GetFieldName(1);

const char* name = (const char*)tempname;

mwArray GetDimensions() const

Description

Determine the size of each dimension in the array. The size of the returned array is 1-by-NumberOfDimensions().

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mwArray dims = a.GetDimensions();

bool IsEmpty() const

Description

Determine if an array is empty.

Example

mwArray a;

bool b = a.IsEmpty();

bool IsSparse() const

Description

Determine if an array is sparse.

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

bool b = a.IsSparse();

bool IsNumeric() const

Description

Determine if an array is numeric.

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

bool b = a.IsNumeric();

bool IsComplex() const

Description

Determine if an array is complex.

Example

mwArray a(2, 2, mxDOUBLE_CLASS, mxCOMPLEX);

bool b = a.IsComplex();

bool Equals(const mwArray& arr) const

Description

Returns true if the input array is byte-wise equal to this array. This method makes a byte-wise comparison of the underlying arrays. Therefore, arrays of the same type should be compared. Arrays of different types will not in general be equal, even if they are initialized with the same data.

Arguments

mwArray& arr

Array to compare to array.

Example

mwArray a(1, 1, mxDOUBLE_CLASS);

mwArray b(1, 1, mxDOUBLE_CLASS);

a = 1.0;

b = 1.0;

bool c = a.Equals(b);

int CompareTo(const mwArray& arr) const

Description

Compares this array with the specified array for order. This method makes a byte-wise comparison of the underlying arrays. Therefore, arrays of the same type should be compared. Arrays of different types will, in general, not be ordered equivalently, even if they are initialized with the same data.

Arguments

mwArray& arr

Array to compare to array.

Example

mwArray a(1, 1, mxDOUBLE_CLASS);

mwArray b(1, 1, mxDOUBLE_CLASS);

a = 1.0;

b = 1.0;

int n = a.CompareTo(b);

int HashCode() const

Description

Constructs a unique hash value form the underlying bytes in the array. Therefore, arrays of different types will have different hash codes, even if they are initialized with the same data.

Example

mwArray a(1, 1, mxDOUBLE_CLASS);

int n = a.HashCode();

mwString ToString() const

Description

Returns a string representation of the underlying array. The string returned is the same string that is returned by typing a variable's name at the MATLAB command prompt.

Example

mwArray a(1, 1, mxDOUBLE_CLASS, mxCOMPLEX);

a.Real() = 1.0;

a.Imag() = 2.0;

printf("%s

", (const char*)(a.ToString()));

mwArray RowIndex() const

Description

Returns an array of type mxINT32_CLASS representing the row indices (first dimension) of this array. For sparse arrays, the indices are returned for just the non-zero elements and the size of the array returned is 1-by-NumberOfNonZeros(). For nonsparse arrays, the size of the array returned is 1-by-NumberOfElements(), and the row indices of all of the elements are returned.

返回阵列元素的行索引;对于稀疏阵列,只返回非零原素的行索引

Example

#include

mwArray a(1, 1, mxDOUBLE_CLASS);

mwArray rows = a.RowIndex();

mwArray ColumnIndex() const

Description

Returns an array of type mxINT32_CLASS representing the column indices (second dimension) of this array. For sparse arrays, the indices are returned for just the non-zero elements and the size of the array returned is 1-by-NumberOfNonZeros(). For nonsparse arrays, the size of the array returned is 1-by-NumberOfElements(), and the column indices of all of the elements are returned.

返回阵列元素的列索引;对于稀疏阵列,只返回非零元素的列索引。

Example

mwArray a(1, 1, mxDOUBLE_CLASS);

mwArray rows = a.ColumnIndex();

void MakeComplex()

Description

Convert a numeric array that has been previously allocated as real to complex. If the underlying array is of a nonnumeric type, an mwException is thrown.

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

double idata[4] = {10.0, 20.0, 30.0, 40.0};

mwArray a(2, 2, mxDOUBLE_CLASS);

a.SetData(rdata, 4);

a.MakeComplex();

a.Imag().SetData(idata, 4);

mwArray Get(mwSize num_indices, ...)

Description

Fetches a single element at a specified index. The index is passed by first passing the number of indices followed by a comma-separated list of 1-based indices. The valid number of indices that can be passed in is either 1 (single subscript indexing), in which case the element at the specified 1-based offset is returned, accessing data in column-wise order, or NumberOfDimensions() (multiple subscript indexing), in which case, the index list is used to access the specified element. The valid range for indices is 1 <= index <= NumberOfElements(), for single subscript indexing. For multiple subscript indexing, the ith index has the valid range: 1 <= index[i] <= GetDimensions().Get(1, i). An mwException is thrown if an invalid number of indices is passed in or if any index is out of bounds.

根据索引返回阵列元素,其中num_indices表示索引数目。Get函数中输入的索引均从1起始。

Arguments

mwSize num_indices

Number of indices passed in

...

Comma-separated list of input indices. Number of items must equal num_indices but should not exceed 32.

Example

double data[4] = {1.0, 2.0, 3.0, 4.0};

double x;

mwArray a(2, 2, mxDOUBLE_CLASS);

a.SetData(data, 4);

x = a.Get(1,1);

x = a.Get(2, 1, 2);

x = a.Get(2, 2, 2);

mwArray Get(const char* name, mwSize num_indices, ...)

Description

Fetches a single element at a specified field name and index. This method may only be called on an array that is of type mxSTRUCT_CLASS. An mwException is thrown if the underlying array is not a struct array. The field name passed must be a valid field name in the struct array. The index is passed by first passing the number of indices followed by a comma-separated list of 1-based indices. The valid number of indices that can be passed in is either 1 (single subscript indexing), in which case the element at the specified 1-based offset is returned, accessing data in column-wise order, or NumberOfDimensions() (multiple subscript indexing), in which case, the index list is used to access the specified element. The valid range for indices is 1 <= index <= NumberOfElements(), for single subscript indexing. For multiple subscript indexing, the ith index has the valid range: 1 <= index[i] <= GetDimensions().Get(1, i). AnmwException is thrown if an invalid number of indices is passed in or if any index is out of bounds.

返回结构体域名为name,指定索引的结构体域,其中num_indices表示索引的数目。Get函数中输入的索引均从1起始。

Arguments

char* name

Null-terminated character buffer containing the name of the field

mwSize num_indices

Number of indices passed in

...

Comma-separated list of input indices. Number of items must equalnum_indices but should not exceed 32.

Example

const char* fields[] = {"a", "b", "c"};

mwArray a(1, 1, 3, fields);

mwArray b = a.Get("a", 1, 1);

mwArray b = a.Get("b", 2, 1, 1);

mwArray Get(mwSize num_indices, const mwIndex* index)

Description

Fetches a single element at a specified index. The index is passed by first passing the number of indices, followed by an array of 1-based indices. The valid number of indices that can be passed in is either 1 (single subscript indexing), in which case the element at the specified 1-based offset is returned, accessing data in column-wise order, or NumberOfDimensions() (multiple subscript indexing), in which case, the index list is used to access the specified element. The valid range for indices is 1 <= index <= NumberOfElements(), for single subscript indexing. For multiple subscript indexing, the ith index has the valid range: 1 <= index[i] <= GetDimensions().Get(1, i). An mwException is thrown if an invalid number of indices is passed in or if any index is out of bounds.

Arguments

mwSize num_indices

Size of index array

mwIndex* index

Array of at least size num_indices containing the indices

Example

double data[4] = {1.0, 2.0, 3.0, 4.0};

int index[2] = {1, 1};

double x;

mwArray a(2, 2, mxDOUBLE_CLASS);

a.SetData(data, 4);

x = a.Get(1, index);

x = a.Get(2, index);

index[0] = 2;

index[1] = 2;

x = a.Get(2, index);

mwArray Get(const char* name, mwSize num_indices, const mwIndex* index)

Description

Fetches a single element at a specified field name and index. This method may only be called on an array that is of type mxSTRUCT_CLASS. An mwException is thrown if the underlying array is not a struct array. The field name passed must be a valid field name in the struct array. The index is passed by first passing the number of indices followed by an array of 1-based indices. The valid number of indices that can be passed in is either 1 (single subscript indexing), in which case the element at the specified 1-based offset is returned, accessing data in column-wise order, or NumberOfDimensions() (multiple subscript indexing), in which case, the index list is used to access the specified element. The valid range for indices is 1 <= index <= NumberOfElements(), for single subscript indexing. For multiple subscript indexing, the ith index has the valid range: 1 <= index[i] <= GetDimensions().Get(1, i). An mwException is thrown if an invalid number of indices is passed in or if any index is out of bounds.

Arguments

char* name

Null-terminated character buffer containing the name of the field

mwSize num_indices

Number of indices passed in

mwIndex* index

Array of at least size num_indices containing the indices

Example

const char* fields[] = {"a", "b", "c"};

int index[2] = {1, 1};

mwArray a(1, 1, 3, fields);

mwArray b = a.Get("a", 1, index);

mwArray b = a.Get("b", 2, index);

mwArray Real()

Description

Accesses the real part of a complex array. The returned mwArray is considered real and has the same dimensionality and type as the original.

Complex arrays consist of Complex numbers, which are 1 X 2 vectors (pairs). For example, if the number is 3+5i, then the pair is (3,5i). An array of Complex numbers is therefore two dimensional (N X 2), where N is the number of complex numbers in the array. 2+4i, 7-3i, 8+6i would be represented as (2,4i) (7,3i) (8,6i). Complex numbers have two components, real and imaginary.

The MATLAB function Realcan be applied to an array of Complex numbers. It extracts the corresponding part of the Complex number. For example,REAL(3,5i) == 3.

返回数值阵列的实部

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

double idata[4] = {10.0, 20.0, 30.0, 40.0};

mwArray a(2, 2, mxDOUBLE_CLASS, mxCOMPLEX);

a.Real().SetData(rdata, 4);

mwArray Imag()

Description

Accesses the imaginary part of a complex array. The returned mwArray is considered real and has the same dimensionality and type as the original.

Complex arrays consist of Complex numbers, which are 1 X 2 vectors (pairs). For example, if the number is 3+5i, then the pair is (3,5i). An array of Complex numbers is therefore two dimensional (N X 2), where N is the number of complex numbers in the array. 2+4i, 7-3i, 8+6i would be represented as (2,4i) (7,3i) (8,6i). Complex numbers have two components, real and imaginary.

The MATLAB function Imag can be applied to an array of Complex numbers. It extracts the corresponding part of the Complex number. For example,IMAG(3+5i) == 5. Imag returns 5 in this case and not 5i. Imag returns the magnitude of the imaginary part of the number as a real number.

返回数值阵列虚部

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

double idata[4] = {10.0, 20.0, 30.0, 40.0};

mwArray a(2, 2, mxDOUBLE_CLASS, mxCOMPLEX);

a.Imag().SetData(idata, 4);

void Set(const mwArray& arr)

Description

Assign shared copy of input array to currently referenced cell for arrays of type mxCELL_CLASS and mxSTRUCT_CLASS.

Arguments

mwArray& arr

mwArray to assign to currently referenced cell

Example

mwArray a(2, 2, mxDOUBLE_CLASS);

mwArray b(2, 2, mxINT16_CLASS);

mwArray c(1, 2, mxCELL_CLASS);

c.Get(1,1).Set(a);

c.Get(1,2).Set(b);

void GetData(* buffer, mwSize len) const

Description

Copies the array's data into supplied numeric buffer.

The data is copied in column-major order. If the underlying array is not of the same type as the input buffer, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

* buffer

Buffer to receive copy. Valid types for are:

mxDOUBLE_CLASS / mxSINGLE_CLASS / mxINT8_CLASS

mxUINT8_CLASS / mxINT16_CLASS / mxUINT16_CLASS

mxINT32_CLASS / mxUINT32_CLASS / mxINT64_CLASS

mxUINT64_CLASS

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

double data_copy[4] ;

mwArray a(2, 2, mxDOUBLE_CLASS);

a.SetData(rdata, 4);

a.GetData(data_copy, 4);

void GetLogicalData(mxLogical* buffer, mwSize len) const

Description

Copies the array's data into supplied mxLogical buffer.

The data is copied in column-major order. If the underlying array is not of type mxLOGICAL_CLASS, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

mxLogical* buffer

Buffer to receive copy

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

mxLogical data[4] = {true, false, true, false};

mxLogical data_copy[4] ;

mwArray a(2, 2, mxLOGICAL_CLASS);

a.SetLogicalData(data, 4);

a.GetLogicalData(data_copy, 4);

void GetCharData(mxChar* buffer, mwSize len) const

Description

Copies the array's data into supplied mxChar buffer.

The data is copied in column-major order. If the underlying array is not of type mxCHAR_CLASS, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

mxChar** buffer

Buffer to receive copy

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

mxChar data[6] = {'H', 'e' , `l' , 'l' , 'o' , ''};

mxChar data_copy[6] ;

mwArray a(1, 6, mxCHAR_CLASS);

a.SetCharData(data, 6);

a.GetCharData(data_copy, 6);

void SetData(* buffer, mwSize len) const

Description

Copies the data from supplied numeric buffer into the array.

The data is copied in column-major order. If the underlying array is not of the same type as the input buffer, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

* buffer

Buffer containing data to copy. Valid types for are:

mxDOUBLE_CLASS / mxSINGLE_CLASS / mxINT8_CLASS

mxUINT8_CLASS / mxINT16_CLASS / mxUINT16_CLASS

mxINT32_CLASS / mxUINT32_CLASS / mxINT64_CLASS

mxUINT64_CLASS

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

double data_copy[4] ;

mwArray a(2, 2, mxDOUBLE_CLASS);

a.SetData(rdata, 4);

a.GetData(data_copy, 4);

void SetLogicalData(mxLogical* buffer, mwSize len) const

Description

Copies the data from the supplied mxLogical buffer into the array.

The data is copied in column-major order. If the underlying array is not of type mxLOGICAL_CLASS, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

mxLogical* buffer

Buffer containing data to copy

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

mxLogical data[4] = {true, false, true, false};

mxLogical data_copy[4] ;

mwArray a(2, 2, mxLOGICAL_CLASS);

a.SetLogicalData(data, 4);

a.GetLogicalData(data_copy, 4);

void SetCharData(mxChar* buffer, mwSize len) const

Description

Copies the data from the supplied mxChar buffer into the array.

The data is copied in column-major order. If the underlying array is not of type mxCHAR_CLASS, the data is converted to this type as it is copied. If a conversion cannot be made, an mwException is thrown.

Arguments

mxChar** buffer

Buffer containing data to copy

mwSize len

Maximum length of buffer. A maximum of len elements will be copied.

Example

mxChar data[6] = {'H', 'e' , `l' , 'l' , 'o' , ''};

mxChar data_copy[6] ;

mwArray a(1, 6, mxCHAR_CLASS);

a.SetCharData(data, 6);

a.GetCharData(data_copy, 6);

static mwArray Deserialize(const mwArray& arr)

Description

Deserializes an array that has been serialized with mwArray::Serialize(). The input array must be of type mxUINT8_CLASS and contain the data from a serialized array. If the input data does not represent a serialized mwArray, the behavior of this method is undefined.

Arguments

mwArray& arr

mwArray that has been obtained by calling mwArray::Serialize

Example

double rdata[4] = {1.0, 2.0, 3.0, 4.0};

mwArray a(1,4,mxDOUBLE_CLASS);

a.SetData(rdata, 4);

mwArray b = a.Serialize();

a = mwArray::Deserialize(b);

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxDouble* rData, mwSize num_rows, mwSize num_cols, mwSize nzmax)

Description

Creates real sparse matrix of type double with specified number of rows and columns.

The lengths of input row, column index, and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated throughout the construction of the matrix.

If any element of the rowindex or colindex array is greater than the specified values in num_rows or num_cols respectively, an exception is thrown.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxDouble* rData

Data associated with non-zero row and column indices

mwSize num_rows

Number of rows in matrix

mwSize num_cols

Number of columns in matrix

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

This example constructs a sparse 4 X 4 tridiagonal matrix:

2 -1 0 0

-1 2 -1 0

0 -1 2 -1

0 0 -1 2

The following code, when run:

double rdata[] =

{2.0, -1.0, -1.0, 2.0, -1.0,

-1.0, 2.0, -1.0, -1.0, 2.0};

mwIndex row_tridiag[] =

{1, 2, 1, 2, 3,

2, 3, 4, 3, 4 };

mwIndex col_tridiag[] =

{1, 1, 2, 2, 2,

3, 3, 3, 4, 4 };

mwArray mysparse =

mwArray::NewSparse(10, row_tridiag,

10, col_tridiag,

10, rdata, 4, 4, 10);

std::cout << mysparse << std::endl;

will display the following output to the screen:

(1,1) 2

(2,1) -1

(1,2) -1

(2,2) 2

(3,2) -1

(2,3) -1

(3,3) 2

(4,3) -1

(3,4) -1

(4,4) 2

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxDouble* rdata, mwSize nzmax)

Description

Creates real sparse matrix of type double with number of rows and columns inferred from input data.

The lengths of input row and column index and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated through out the construction of the matrix.

The number of rows and columns in the created matrix are calculated form the input rowindex and colindex arrays as num_rows = max{rowindex}, num_cols = max{colindex}.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxDouble* rData

Data associated with non-zero row and column indices

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

In this example, we construct a sparse 4 X 4 identity matrix. The value of 1.0 is copied to each non-zero element defined by row and column index arrays:

double one = 1.0;

mwIndex row_diag[] = {1, 2, 3, 4};

mwIndex col_diag[] = {1, 2, 3, 4};

mwArray mysparse =

mwArray::NewSparse(4, row_diag,

4, col_diag,

1, &one,

0);

std::cout << mysparse << std::endl;

(1,1) 1

(2,2) 1

(3,3) 1

(4,4) 1

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxDouble* rdata, const mxDouble* idata, mwSize num_rows, mwSize num_cols, mwSize nzmax)

Description

Creates complex sparse matrix of type double with specified number of rows and columns.

The lengths of input row and column index and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated through out the construction of the matrix.

If any element of the rowindex or colindex array is greater than the specified values in num_rows, num_cols, respectively, then an exception is thrown.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxDouble* rData

Real part of data associated with non-zero row and column indices

mxDouble* iData

Imaginary part of data associated with non-zero row and column indices

mwSize num_rows

Number of rows in matrix

mwSize num_cols

Number of columns in matrix

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

This example constructs a complex tridiagonal matrix:

double rdata[] = {2.0, -1.0, -1.0, 2.0, -1.0, -1.0, 2.0, -1.0, -1.0, 2.0};

double idata[] = {20.0, -10.0, -10.0, 20.0, -10.0, -10.0, 20.0, -10.0, -10.0, 20.0};

mwIndex row_tridiag[] = {1, 2, 1, 2, 3, 2, 3, 4, 3, 4};

mwIndex col_tridiag[] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4};

mwArray mysparse = mwArray::NewSparse(10, row_tridiag,

10, col_tridiag,

10, rdata,

idata, 4, 4, 10);

std::cout << mysparse << std::endl;

It displays the following output to the screen:

(1,1) 2.0000 +20.0000i

(2,1) -1.0000 -10.0000i

(1,2) -1.0000 -10.0000i

(2,2) 2.0000 +20.0000i

(3,2) -1.0000 -10.0000i

(2,3) -1.0000 -10.0000i

(3,3) 2.0000 +20.0000i

(4,3) -1.0000 -10.0000i

(3,4) -1.0000 -10.0000i

(4,4) 2.0000 +20.0000i

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxDouble* rdata, const mxDouble* idata, mwSize nzmax)

Description

Creates complex sparse matrix of type double with number of rows and columns inferred from input data.

The lengths of input row and column index and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated through out the construction of the matrix.

The number of rows and columns in the created matrix are calculated form the input rowindex and colindex arrays as num_rows = max{rowindex}, num_cols = max{colindex}.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxDouble* rData

Real part of data associated with non-zero row and column indices

mxDouble* iData

Imaginary part of data associated with non-zero row and column indices

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

This example constructs a complex matrix by inferring dimensions and storage allocation from the input data.

mwArray mysparse =

mwArray::NewSparse(10, row_tridiag,

10, col_tridiag,

10, rdata, idata,

0);

std::cout << mysparse << std::endl;

(1,1) 2.0000 +20.0000i

(2,1) -1.0000 -10.0000i

(1,2) -1.0000 -10.0000i

(2,2) 2.0000 +20.0000i

(3,2) -1.0000 -10.0000i

(2,3) -1.0000 -10.0000i

(3,3) 2.0000 +20.0000i

(4,3) -1.0000 -10.0000i

(3,4) -1.0000 -10.0000i

(4,4) 2.0000 +20.0000i

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxLogical* rdata, mwSize num_rows, mwSize num_cols, mwSize nzmax)

Description

Creates logical sparse matrix with specified number of rows and columns.

The lengths of input row and column index and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated throughout the construction of the matrix.

If any element of the rowindex or colindex array is greater than the specified values in num_rows, num_cols, respectively, then an exception is thrown.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxLogical* rData

Data associated with non-zero row and column indices

mwSize num_rows

Number of rows in matrix

mwSize num_cols

Number of columns in matrix

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

This example creates a sparse logical 4 X 4 tridiagonal matrix, assigning true to each non-zero value:

mxLogical one = true;

mwIndex row_tridiag[] = {1, 2, 1, 2, 3, 2, 3, 4, 3, 4};

mwIndex col_tridiag[] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4};

mwArray mysparse =

mwArray::NewSparse(10, row_tridiag,

10, col_tridiag,

1, &one,

4, 4, 10);

std::cout << mysparse << std::endl;

(1,1) 1

(2,1) 1

(1,2) 1

(2,2) 1

(3,2) 1

(2,3) 1

(3,3) 1

(4,3) 1

(3,4) 1

(4,4) 1

static mwArray NewSparse(mwSize rowindex_size, const mwIndex* rowindex, mwSize colindex_size, const mwIndex* colindex, mwSize data_size, const mxLogical* rdata, mwSize nzmax)

Description

Creates logical sparse matrix with number of rows and columns inferred from input data.

The lengths of input row and column index and data arrays must all be the same or equal to 1. In the case where any of these arrays are equal to 1, the value is repeated through out the construction of the matrix.

The number of rows and columns in the created matrix are calculated form the input rowindex and colindex arrays as num_rows = max {rowindex}, num_cols = max {colindex}.

Arguments

mwSize rowindex_size

Size of rowindex array

mwIndex* rowindex

Array of row indices of non-zero elements

mwSize colindex_size

Size of colindex array

mwIndex* colindex

Array of column indices of non-zero elements

mwSize data_size

Size of data array

mxLogical* rData

Data associated with non-zero row and column indices

mwSize nzmax

Reserved storage for sparse matrix. If nzmax is zero, storage will be set tomax{rowindex_size, colindex_size, data_size}.

Example

This example uses the data from the first example, but allows the number of rows, number of columns, and allocated storage to be calculated from the input data:

mwArray mysparse =

mwArray::NewSparse(10, row_tridiag,

10, col_tridiag,

1, &one,

0);

std::cout << mysparse << std::endl;

(1,1) 1

(2,1) 1

(1,2) 1

(2,2) 1

(3,2) 1

(2,3) 1

(3,3) 1

(4,3) 1

(3,4) 1

(4,4) 1

static mwArray NewSparse (mwSize num_rows, mwSize num_cols, mwSize nzmax, mxClassID

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/421498.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

NSARRAY的 内存管理

一个对象加入到nsarray里内存计数器会1,当这个nsarrayrelease的时候,回自动减1,程序员不需要管理这方面的内存.转载于:https://www.cnblogs.com/gm-lotus/p/3349509.html

blender怎么移动骨骼,Blender学习笔记-(015)创建骨骼绑定及权重绘制操作详解

骨骼创建绑定具体操作如下&#xff1a;1&#xff1a; 【ShiftA】创建基础骨骼。(也可以通过打开Blender的插件Rigging&#xff1a;Rigify&#xff0c;生成自定义骨骼)2&#xff1a;点击骨骼&#xff0c;按【Tab】键进入编辑模式&#xff0c;选中创建骨骼端&#xff0c;按【E】拖…

[MySQL binlog实战] 增量同步与数据搜索~从入门到精通

学习基础知识&#xff0c;并落实到实际场景&#xff08;增量同步数据搜索&#xff09; 对基础知识不感兴趣的&#xff0c;可以直接跳到应用场景 文章目录 binlog是什么简介产生方式文件格式statementrowmixed 怎么办开启 binlog查看 binlog其他查看相关命令运维查看 binlog设置…

从硬核科幻小说《三体》中看嵌入式

1 2 3 4 5 6 7 8 9 转载于:https://www.cnblogs.com/OleNet/p/3352189.html

matlab潮流计算求节点自导纳,大神们,求个电力系统潮流计算的matlab程序。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼ninput(Please input n\n); %n表示系统的节点数d0input(Please input d0\n); %d0表示系统的误差minput(Please inpit m\n); %m表示系统的pq节点的个数p0ones(n-1,1);q0ones(m,1);d1;dpvones(n-1,1);dqvones(m,1);dpzeros(n-1,1);dq…

早晨爬山,三餐自备——程序员也可以这样生活、工作

没有参加工作以前&#xff0c;在香港及国外的电影里经常会有在家吃了自做早餐后再悠闲的去上班的情节&#xff0c;当时充满了向往。 从事程序开发以来&#xff0c;电脑前坐12个小时是常态&#xff0c;坐14个小时不稀奇&#xff0c;坐14个小时以上十有一二。而早餐&#xff1f;经…

php快速排序和二分查找法,二分查找及快速排序

小朋友二分查找和快速排序思想上有很大的相似度&#xff0c;就是做一个起始点&#xff0c;开始往左右做动作&#xff0c;也同样是由递归实现&#xff0c;当然也可以不用递归实现。但是我觉得也不能用php内置特有的函数- -&#xff0c;我找了很多php的快速排序&#xff0c;几乎都…

php 三目格式,PHP-您使用哪种编码风格的三元运算符?

PHP-您使用哪种编码风格的三元运算符&#xff1f;如果很短&#xff0c;我将其放在一行中。 最近&#xff0c;我一直在将这种样式用于较长或嵌套的三元运算符表达式。 一个人为的例子&#xff1a;$value ( $a $b )? true value # 1: ( $a $c )? true value # 2: false valu…

extractCSS – 帮助你从 HTML 中快速分离出 CSS

extractCSS 是一个免费的基于 Web 的应用程序&#xff0c;能够从 HTML 中提取风格相关的信息&#xff0c;包括 id、class 和内联样式&#xff0c;而且输出可以定制&#xff08;缩进和括号的用法&#xff09;。该工具非常有用&#xff0c;当我们快速创建一个使用了内联样式的 HT…

php项目安装器,php项目安装器程序源码,php通用安装程序

php项目安装器程序源码,php通用安装程序一个安装器的源码&#xff0c;最简单的看一下emlog 也可以&#xff01;文件目录结构index.php 程序首页│ ├─conf 安装后配置文件目录├─data    目录写入测试目录└─install 安装程序目录 │ index.php   安装程…

7zip File: How to Uncompress 7z files on Ubuntu, Debian, Fedora

转&#xff1a;http://www.thegeekstuff.com/2010/04/7z-7zip-7za-file-compression/ Question: How do I uncompress a *.7z file ( 7zip file ) in UNIX / Linux ? Can you explain with a simple example? Answer: Use 7za command to unzip a 7z file ( 7zip file ) on U…

php找不到邮件类,SMTP无法使用php邮件程序类

我有两个帐户&#xff1a;no-replyweddinggrabs.comno-replyappovio.com和传入POP3&#xff1a;pop.secureserver.net(995)传出SMTP&#xff1a;smtpout.secureserver.net(80,3535,25,465)这些工作使用电子邮件客户端,如Thunderbird,post-box等,但不使用php-mailer&#xff1a;…

Python开发环境Wing IDE 5.0测试第八版发布

Wing IDE是著名的Python开发工具&#xff0c;是Wingware公司的主要产品。从1999年起&#xff0c;Wingware公司便开始专注于Python开发设计。Wing IDE在十几年的发展中&#xff0c;不管完善。其强大设计理念包括&#xff1a;编辑工具丰富&#xff0c;编译测试版权一体化&#xf…

PHP5比PHP4,php4和php5的配置异同比较

技术文章配置php4或者php5的过程中&#xff0c;php4&#xff0c;5的配置的步骤大致一样的&#xff0c;但是配置内容有一些差别。在LINUX等环境下编译&#xff0c;一般来说&#xff0c;只要编译的选项正确&#xff0c;配置也就正确了&#xff1b;在windows配置则需要注意以下不同…

matlab文件序号超出511,求教一段matlab的代码 - 数学 - 小木虫 - 学术 科研 互动社区...

不知楼主说的没法求出优化值&#xff0c;是什么意思。是报错还是怎么。我也是刚接触优化&#xff0c;觉得楼主的错误可能是在&#xff1a;主函数里 A[-1;1];的括号中间应该用逗号&#xff0c;而不是分号。即改为A[-1,1];我对你的程序做了一点改动&#xff0c;如下&#xff1a;f…

系统地学习JavaScript

入门 学会DIVCSS布局使用DIVCSS布局标准网页&#xff0c;可以使前端XHTML代码更少、结构更清晰&#xff0c;这有利于轻松用JavaScript操作DOM&#xff0c;比如&#xff0c;要展示一个3 行3列的列表&#xff0c;如果用传统的表格布局&#xff0c;现在要你用JavaScript动态生成这…

matlab this指针,C++ this指针(直戳本质)

为了能让大家看清 this 指针的本质&#xff0c;我们会先讲一点 C 的历史——C 程序到C程序的翻译过程。C 程序到C程序的翻译C 是在C语言的基础上发展而来的&#xff0c;第一个 C 的编译器实际上是将 C 程序翻译成C语言程序&#xff0c;然后再用C语言编译器进行编译。C语言没有类…

WPF自定义控件 —— 装饰器

摘自&#xff1a;http://www.cnblogs.com/Curry/archive/2009/09/16/1567757.html 顾名思义就是装饰用的&#xff0c;也就是说不改变原有的控件结构&#xff0c;但可以为控件添加一些新的功能&#xff0c;或是为控件的显示外观增加些东西。如MSDN中的例子&#xff1a; 本来Text…

matlab填充点面,求大神指点绘制空间内散点图的包络面,,,散点程序如下

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼E[];a0;b0;c0;for Zp-50:2:50for Xp-200:2:200for Yp-200:2:200P1_1[cos(b)*cos(c) -cos(b)*sin(c) sin(b) Xp;sin(a)*sin(b)*cos(c)cos(a)*sin(c) cos(a)*cos(c)-sin(a)*sin(b)*sin(c) -sin(a)*cos(b) Yp;sin(a)*sin(c)-cos(a)*si…