use rows of matrix sequentially in iterations
1 次查看(过去 30 天)
显示 更早的评论
Hi I have 2 matrices A and B. each of them has 4 rows and 10 columns. Also, I have the other matrix (D) 100 rows, 100 columns and 6 in third dimension. this matrix is (0-1)matrix. I want to use A and B as index. In fact, my code is something like that:
for it = 1:30
p = randi(80,100,100,6)
for k=1:4
IDX=A(k,:)
JDX=B(k,:)
end
for i:IDX
for j=JDX
s=find(D(i,j,:)==1)
t=s.*p
end
end
end
I hope that in each iteration 100 values for s are determined. and in each iteration one row of A and one row of B are used as IDX and JDX respectively. I mean in iteration 1 for example the first row of A and B, for iteration two the second row of A and B and for iteration 3 the third row and column of A and B. Thank you.
2 个评论
Stephen23
2015-11-6
Today I formatted your code for you, but in future please do it yourself by selecting the code text and clicking the {} Code button.
Also its helps everyone (yourself included) when you use consistent indentation, like I edited your code to have.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!