linear index to matrix index

3 次查看(过去 30 天)
ola,
I have a matrix 1020x1294, and the linear index 475000. I can do the math by myself, but I'd like to know is there a function that calculates what is the row&column of this index in the matrix?
thanks
  3 个评论
yonatan s
yonatan s 2018-2-1
no reason. why does it matter?
Birdman
Birdman 2018-2-1
Just wondered. It does not matter.

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2018-2-1
ii = 475000;
m = size(A,1);
r = rem(ii,m);
c = ceil(ii/m);

更多回答(1 个)

Birdman
Birdman 2018-2-1
编辑:Birdman 2018-2-1
One approach:(use ind2sub)
A=randi([1 5],1020,1294);%demo data
[r,c]=ind2sub(size(A),475000)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by