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

2 views (last 30 days)
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.
The Answer I got was:
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 :)

Answers (1)

the cyclist
the cyclist on 8 Oct 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.

Community Treasure Hunt

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

Start Hunting!