Considering a 3D matrix. How to delete the first column of the first matrix, the second column of the second matrix, the third column of the third matrix and so on.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mariana
am 21 Nov. 2017
Beantwortet: Image Analyst
am 21 Nov. 2017
% Considering 3D matrix of dimension n
n=3;
for a=1:n
for b=1:n
for c=1:n
A(b,c,a)=c;
end
end
end
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 21 Nov. 2017
For example, try this:
% Create sample data: cube of size n.
n=3;
m = randi(9, n, n, n)
% Create output array.
output = zeros(n, n-1, n);
for z = 1 : size(m, 3)
thisPlane = m(:,:,z);
columnToRemove = z;
% Remove column by setting all elements of the column to null.
thisPlane(:, columnToRemove) = [];
% Assign narrower matrix to the zth plane of the output.
output(:,:,z) = thisPlane;
end
% Print to command window.
output
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!