在Matlab中缩短stuct/class名称的句柄 [英] a handle to shorten the name of stuct/class in matlab

查看:85
本文介绍了在Matlab中缩短stuct/class名称的句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有相对复杂的数据树的结构.例如:

I have a struct with relative sophisticated data trees. for example:

class.data.head{1}.data2

我希望获得一个名为 data2_link 的变量,该变量与地址 class.data.head {1} .data2 链接,以便:

What I wish to get is a variable named data2_link to link with address class.data.head{1}.data2, so that:

(1)如果 class.data.head {1} .data2 有任何更改,它也会自动反映到 data2_link ,反之亦然.

(1) if there is any change on class.data.head{1}.data2, it will automatically reflected to data2_link as well, and vise versa.

(2)我不必键入长名即可访问 class.data.head {1} .data2 上的数据.

(2) I do not have to type the long name to access the data at class.data.head{1}.data2.

谢谢!

推荐答案

Matlab不支持引用.唯一的例外是handle,它允许引用对象.

Matlab does not support references. The only exception is handle which allows references to objects.

要使用它,data2必须是具有超类handle的对象,那么您可以简单地编写:

To use it, data2 must be an object with superclass handle, then you could simply write:

data2_link=class.data.head{1}.data2

请注意,面向对象的Matlab 明显减慢了您的代码,除非您使用Matlab 2015b或更高版本.

Note that object oriented matlab significantly slows down your code unless you use Matlab 2015b or newer.

这篇关于在Matlab中缩短stuct/class名称的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆