Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How to edit elements per row in a 3D-matrix using a vextor with (X,Y,Z)-coordinates indecating a first index and a last index. All elements between these two shall be '1'. If possible without a loop to be most efficient
2 ビュー (過去 30 日間)
古いコメントを表示
I have 3D matrix with Zeros, e.g. A=zeros(10,10,3); Also I've "start-coordinates" and "stop-coordinates" for each Dimension (1st Dim = 1st row, 2nd Dim = 2nd Row, 3rd Dim. = 3rd row):
Start=[3,2,5,6,7,2,1,1,5,5; 1:10; 1:10];
Stop=[9,9,9,9,9,9,9,9,9,9; 2:10, 10; 4:10, 10, 10, 10];
These Coordinates shall now be visible in the Matrix and the elements between them shall all be '1', like this (example 1st Dimension): B(:,:,1)=
0 0 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 0 1 1 0
0 0 0 0 0 0 1 1 1 0
0 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 1 0
0 0 0 0 1 1 1 1 1 0
with:
Start(1,:) =
3 2 5 6 7 2 1 1 5 5
and Stop(1,:))=
9 9 9 9 9 9 9 10 9 9
Analog for B(:,:,2) and B(:,:,3) using Start/Stop(2,:) and Start/Stop(3,:);
I tried reshaping the start/stop coordinates and tried using "sub2ind" but I couldn't get the result I wanted for the three Dimension, it was just working for a 2D-Matrix (e.g. A=zeros(10,10)).
Unfortunatley the matrix in my program is even bigger which is why efficiency is very important. That's why I'd rather avoid loops. Thanks a lot!
0 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!