Clear Filters
Clear Filters

I want to collect the smallest arrays on the 3rd axis and get a 2d image.

1 view (last 30 days)
i have a 3X3X3 double data
a=[1 1 1;10 10 10;10 10 10];
b=[20 20 20;2 2 2;20 20 20];
c=[30 30 30;30 30 30;3 3 3];
d=cat(3,a,b,c);
To illustrate, let's say 3X3X3 is row, column, page.
I want to find the minimum value several pages with fixed rows and columns.
I think repeating this would make one 3X3 matrix in each row and column.
I think it's possible if i use "for loops" to find it. But can't do this using "min()"?
% i want get e=[1 1 1 ;2 2 2; 3 3 3]
e=[1 1 1 ;2 2 2; 3 3 3]
e = 3×3
1 1 1 2 2 2 3 3 3

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 6 Jul 2023
a=[1 1 1;10 10 10;10 10 10];
b=[20 20 20;2 2 2;20 20 20];
c=[30 30 30;30 30 30;3 3 3];
d=cat(3,a,b,c);
out=min(d,[],3)
out = 3×3
1 1 1 2 2 2 3 3 3
  1 Comment
영훈 정
영훈 정 on 6 Jul 2023
a=[1 1 1;10 10 10;10 10 10];
b=[20 20 20;2 2 2;20 20 20];
c=[30 30 30;30 30 30;3 3 3];
d=cat(3,a,b,c);
out=min(d,[],3)
out = 3×3
1 1 1 2 2 2 3 3 3
out=min(d,3)
out =
out(:,:,1) = 1 1 1 3 3 3 3 3 3 out(:,:,2) = 3 3 3 2 2 2 3 3 3 out(:,:,3) = 3 3 3 3 3 3 3 3 3
%I was stupid

Sign in to comment.

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!