# How can I find the Difference between the Min and Max of all matching cells over different matrices?

2 Ansichten (letzte 30 Tage)
Robert am 8 Okt. 2014
Beantwortet: the cyclist am 8 Okt. 2014
I already asked this question and thought i was satisfied wth the answer, but turns out i'm not.
Basically I have 12 matrices each for a month of the year (33x45). For each cell I want to know the difference between the max and min values recorded for the entire year.
I then want an output that is another matrix with the resulting differences in the appropriate cells.
I would put the 12 matrices in a 33x45x12 matrix.
Then you can simply call
max(x,3)-min(x,3)
the '3' refers to take the maximum along the 3rd dimension of x.
This sort of works, problem is that the result is another 33x45x12 matrix, where as it should just be a 33x45 matrix
Can I alter the "max(x,3)-min(x,3)" code to do this?
Any further help would be greatly appriciated - Matlab newbie :)
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

the cyclist am 8 Okt. 2014
I think you actually need the syntax
max(x,[],3) - min(x,[],3)
to work along the 3rd dimension.
The syntax you are using will simply take the max of x and the number 3, element-by-element.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### 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!

Translated by