在MATLAB重塑阵列 [英] Reshaping arrays in MATLAB

查看:140
本文介绍了在MATLAB重塑阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1024大小为1024的二进制数组3D由1024我想用一个函数( convhull ),它具有以下输入:

I have a binary 3D array of the size 1024 by 1024 by 1024. I want to use a function (convhull), which has the following input:

X是大小MPTS逐NDIM,其中MPTS是点和NDIM的数量是其中点所在的空间,2≦NDIM≦3 ​​

X is of size mpts-by-ndim, where mpts is the number of points and ndim is the dimension of the space where the points reside, 2 ≦ ndim ≦ 3

我怎样才能重塑我的数组,由本功能的阵列型X?

How can I reshape my array into the array X which is required by this function?

也许重塑是不是最好的词,因为使用重塑的功能是远远不够的。

Maybe "reshape" isn't the best word, because using the "reshape" function isn't enough.

推荐答案

什么 convhull 正在寻找的是你的数组中的非零元素的下标列表。给定一个三维数组 M

What convhull is looking for is a list of subscripts of nonzero elements in your array. Given a 3D array M:

[X,Y,Z] = ind2sub(size(M), find(M));

然后使用这些在 convhull

convhull(X, Y, Z);

您在你的问题提的孤独 X 参数仅仅是串联这三个列向量:

The lone X parameter you mention in your question is just these three column vectors concatenated:

X = [X Y Z];
convhull(X);

这篇关于在MATLAB重塑阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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