Reputation: 1304
lets say that we have the next series of arrays:
A = [1, 2, -2, -24];
B = [1, 4, -7, -2];
C = [3, 1, -7, -14];
D = [11, 4, -7, -1];
E = [1, 2, -3, -4];
F = [5, 14, -17, -12];
I would like to create two arrays, the first will be the maximum of each column for all arrays, i.e.
Maxi = [11,14,-2 -1];
the second will be the minimum of each column for all arrays i.e.
Mini= [1,1,-17 -24];
I am trying all day, using loops, with max, and abs but I cant make it work
in my problem have a matrix (100,200), so with the above example i am trying to easily approach the problem. The ultimate goal is to get a kinda fitting of the 100 y_lines of 200 x_points. The idea is to calculate two lines (i.e. max,min), that will be the "visual" boarders of all lines (maximum and minimum values for each x). The next step will be to calculate an array of the average of these two arrays, so in the end will be a line between all lines.
any help is more than welcome!
Upvotes: 0
Views: 798
Reputation: 1972
How about this?
Suppose you stack all the row vectors , namely A,B...,F
as
arr=[A;B;C;D;E;F];% stack the vectors
And then use the max()
, min()
and mean()
functions provided by Matlab
. That is,
Maxi = max(arr); % Maxi is a row vector carrying the max of each column of arr
Mini = min(arr);
Meani = mean(arr);
You just have to stack them as shown above. But if you have 100s of row vectors, use a loop to stack them into array arr
as shown above.
Upvotes: 2