How do I find a min/max value within a defined range for each column of a matrix?

74 Ansichten (letzte 30 Tage)
I am sure this is so simple but I can't work it out. I have a 513*86 array where the columns are the variables and the rows are the samples that represent a time series of EEG data sampled at 256 Hz. I want to find the maximum and minimum values between the 200th and 400th rows. I can't seem to make this work. Any help would be so appreciated! Thanks Kim

Akzeptierte Antwort

Kim
Kim am 4 Feb. 2013
Thank you so much for such a quick answer! I tried your code but I still have one problem.
I forgot to mention (sorry) I need it's index too. The code that I was using for one row of data was:
[minval,minindex] = min(meandata(N4index:P6index)); Where meandata is a vector representing a time averaged data series. The indexes are just time points found with the 'find' function but are about 200 and 400. I tried this
a=data(N4index:P6index,:); % isolate the section of interest? [min1,minindex]=min(a(:))
This returns a row vector of columns data, but it is the same number? Am I missing something?
Thanks again Kim

Weitere Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 4 Feb. 2013
x=rand(513,86);
a=x(200:400,:);
min1=min(a(:))
max1=max(a(:))
  1 Kommentar
Azzi Abdelmalek
Azzi Abdelmalek am 5 Feb. 2013
x=rand(513,86);
a=x(200:400,:);
[min1,idx1]=min(a(:))
[max1,idx2]=max(a(:))
[ii1,jj1]=ind2sub([200 86],idx1)
[ii2,jj2]=ind2sub([200 86],idx2)
ii1=ii1+200;
ii2=ii2+200;
disp([min1,ii1,jj1]);
disp([max1 ii2 jj2]);

Melden Sie sich an, um zu kommentieren.


Mohammadhassan safavi
Mohammadhassan safavi am 30 Okt. 2018
here is the code: X is original data set, A is subset within the range
range =L:U;
A = X(range);
[value index]=max(A);
org_index= range(index);

Community Treasure Hunt

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

Start Hunting!

Translated by