Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How do I store a maximum value from a 3-d matrix to a 2-d matrix?

1 Ansicht (letzte 30 Tage)
vishav Rattu
vishav Rattu am 22 Feb. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I have a 3-d matrix z with variables x, y and s. I want to store the maximum value of z over s in a new matrix with variables x and y only. How should I do it?
if true
% code
end
x = 1:32;
y = 1:32;
s = 1:20;
[X,Y,S]= ndgrid(x,y,s);
z= X.^2 + Y.^2 -2.*X.*S +Y.*S;
%Now how do I store maximum of z in a new matrix called zmax(x,y)%

Antworten (1)

Walter Roberson
Walter Roberson am 22 Feb. 2017
zmax = min(z, [], 3);
  2 Kommentare
vishav Rattu
vishav Rattu am 23 Feb. 2017
Shouldn't it be max(z,[],3) and also will this matrix be a 2-d matrix?
Walter Roberson
Walter Roberson am 23 Feb. 2017
Yes sorry max rather than min. The result will be 2d.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by