Matlab中的phytree对象到底是什么? [英] what exactly is the phytree object in matlab?

查看:81
本文介绍了Matlab中的phytree对象到底是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题困扰了我一段时间,因此我将其发布在这里,以防其他人遇到类似的问题.在调试代码以使其打印出变量后,我了解到phytree对象是具有三个字段的结构数组,即tree,dist和name.在这里,树是一个矩阵,其大小是分支数乘以 2.但是由于数据很大,我无法弄清楚到底什么是矩阵树.有人可以帮忙吗?提前致谢.

This question has bothered me for a while, so I post it here just in case someone else has the similar issue. After debugging the code to ask it print out the variables, I understand that the phytree object is a struct array with three fields, i.e., tree, dist and names. Here, tree is a matrix with the size the number of branches times 2. But because the data is large, I cannot quite figure out what exactly is the matrix tree. Can someone help? Thanks in advance.

推荐答案

seqneighjoin 的输出不是具有字段 tree dist names ,它是一个 phytree 对象,具有一些内部属性,称为 tree dist 名称.由于已经使用调试器查看了代码,因此请查看 phytree.m 末尾的行-您将看到它指定了输出tr phytree 类的对象,而不是结构.

The output of seqneighjoin is not a struct array with the fields tree dist and names, it's a phytree object that has some internal properties called tree, dist and names. Since you're already taking a look at the code with the debugger, take a look at the line right at the end of phytree.m - you'll see that it specifies that the output tr is an object of class phytree, not a struct.

我不确定您是否在MATLAB中使用面向对象的程序有很多背景知识,但这是一个比我在这里讨论的话题还大的话题-我只是说一个对象"是具有属性的东西以与结构具有存储信息的字段相同的方式存储信息;但是对象还具有方法,这些方法作为对象的一部分存储并对其起作用.对于 phytree 对象,这些方法具有以下功能,例如用于删除分支的 prune ,用于获取Newick格式的字符串的 getnewickstr 等.

I'm not sure if you have much background using object-oriented programming in MATLAB, but it's a bigger topic than I can discuss here - I'll just say that an "object" is something that has properties that store information in the same way that a struct has fields that store information; but an object also has methods that are functions stored as part of the object and that act on it. For the phytree object, these methods are functions such as prune for removing branches, getnewickstr for getting a Newick-formatted string, and so on.

您可以在文档中找到有关MATLAB OO编程的更多信息.不幸的是,这存在一个问题-在R2008a中,MATLAB引入了一种新的OO形式,并且当前所有文档均基于该OO样式. phytree 是使用旧版的OO实现的,因此您可能需要查看旧版MATLAB的文档以了解其语法.

You can find out more about MATLAB OO programming in the documentation. Unfortunately, there's a bit of an issue with that - in R2008a, MATLAB introduced a new form of OO, and all the current documentation is based on that style of OO. phytree is implemented using the old style of OO, so you may need to look at the doc for an old version of MATLAB to find out its syntax.

您不应该尝试直接访问内部的 tree 属性.如果要获取它,请使用 get(tr,'Pointers').这是一个数组,列出了哪些分支连接到其他分支/叶子.

You shouldn't be trying to access the internal tree property directly. If you want to get it, use get(tr, 'Pointers'). It's an array listing which branches are connected to which other branches/leaves.

这篇关于Matlab中的phytree对象到底是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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