簡體   English   中英

在Matlab中轉換(x,y)坐標

[英]Convert (x,y) coordinates in Matlab

在Matlab中,我有這個矩陣:

尺寸為[x,y] Grid

我已經將其重塑為單行矩陣

Row尺寸為[1,x*y]

我怎么知道在矩陣Row(1,?)哪里找到坐標Grid(x,y) ,反之亦然? Matlab中有此功能嗎?

是的,您正在尋找sub2indind2sub函數。 我認為。

函數sub2indind2sub應該是您想要的。

您能否提供有關如何“轉換矩陣”的更多信息?

標准方法是使用B = reshape(A,m,n) ,這可以在Matlab文檔中找到, 網址http://www.mathworks.com/help/techdoc/ref/reshape.html

重塑:

返回m×n矩陣B,其元素從A處按列取。如果A沒有m * n個元素,則會導致錯誤。

例如,

 a = [1,2,3;4,5,6;7,8,9]

     1     2     3
     4     5     6
     7     8     9


reshape(a,9,1)

     1
     4
     7
     2
     5
     8
     3
     6
     9

因此,可以使用sub2ind(matrixSize,rowSub,colSub),即

sub2ind([3,3], 2, 3)

如預期的那樣,將產生8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM