主要内容

matlab:: data:: ObjectArray

c++类访问MATLAB对象数组

描述

使用ObjectArray对象访问MATLAB®对象数组。创建一个ObjectArray,叫createArrayArrayFactory类使用以下语法:

template  TypedArray createArray(ArrayDimensions dimms, ItType开始,ItType结束)

要创建标量对象,调用createScalar使用这种语法:

const Object& val (const对象);

ObjectArray被定义为:

使用ObjectArray = TypedArray;
            
            

类细节

名称空间:

matlab:数据

包括:

ObjectArray.hpp

的元素不能组合ObjectArray进入异构阵列。

如果类定义对象覆盖subsrefsubsasgn的元素,则不能访问ObjectArray

例子

创建ObjectArray

创建一个ObjectArraymyObject类对象。迭代器是指向数组开头和结尾的指针。

类myObject {public: const std::vector& getObjs() const{返回fObjs;} private: std::vector fobjects;};const myobject a1;const myobject a2;matlab::数据::ArrayFactory工厂;const auto& objs = a1.getObjs();数据::ObjectArray arr1 =工厂。createArray({1,2}, objs.begin(), objs.end());

遍历ObjectArray

使用基于范围的for循环遍历ObjectArray并检索数组中的对象。

std::矢量对象> < matlab::数据::fObjs;//使用基于范围的for循环遍历对象。for (const auto& o: objs) {fObjs.push_back(o);}

对象在MEX和引擎应用程序

c++ MEX和c++ Engine应用程序可以获取和设置MATLAB对象的属性值。有关如何在这些应用程序中访问MATLAB对象的信息,请参阅以下主题:

介绍了R2017b