I have a set of measurements of a process performed in cycles (labeled as O). The set of data contains one x-axis and multiple y values. For each y column i.e. each measurement cycle, I want to find its maxiumum value and to match it to corresponding value on x scale (first column in data set).
When I try with match function I obtain a nested array as a result. Is there a way to present nested array to set of (x,y) data?
Solved! Go to Solution.
Guess the attached file should help.
The first approach is using the range varaible similar to your approach but will only consider the first of multiple max values.
The second approach is a small program which should take care of multiple max values per column as well.
1) You get 0 for IndMax[0 because your range variable i is running beginning from 1 (you don't need the max of the x column) but vectors always begin with index 0 (unless you change the system variable ORIGIN). So IndMax[0 never is assigned a value and defaults to zero.
2) match() will always return a vector of indices, even if there is just one item found. You are searching in the whole matrix O for the value, so match has to return row and column (in a vector) as result. Thats the reason why the elements of your vector IndMax are nested vectors. Think you better search only in the appropriare column of O and use the index obtained to lookup the x-value in the first column.
Some questions:
Thats the reason why the elements of your vector IndMax are nested vectors. Think you better search only in the appropriare column of O and use the index obtained to lookup the x-value in the first column.
The thing is that I need maximum values of each i.e. 192 columns.
- What kind of data structure do you have on mind for your x,y pairs? With the data you provide you will get at least 192 pairs. Should it be a 192x2 matrix or do you need a 192 element vector consisting of 1x2 or 2x1 vectors, or something else?
The most approptiate presentation would be 192x2 matrix i.e. 192 rows and 2 columns. The values should be the same as the one obtained in nested arrays.
- What should happen if a y-column contains the maximum value more than once? Should only the first occurence be taken or do you need all in your result.
I dont expect that there are two or more same y values within one column. However, if that is the case I would need all in my result.
P.S.
Maybe the approach with range variable I used is not the best. I have nothing against if there is another approach which can analyze matrix columns, search for maximum and give row index where the max value is.
Thanks
Guess the attached file should help.
The first approach is using the range varaible similar to your approach but will only consider the first of multiple max values.
The second approach is a small program which should take care of multiple max values per column as well.
Thanks Werner! The second approach is quite elegant way to find multiple maxima of y values and to match them with corresponding x.