find values in a matrix above a threshold

113 views (last 30 days)
Maria Mateus
Maria Mateus on 17 Oct 2013
Commented: Azzi Abdelmalek on 17 Oct 2013
My matrix has:
column A: Month
column B: Day
column C: Year
column D: Discharge
I need to know the Month, Day, Year and the discharge that goes above threshold in a time series of data that goes from 01-01-2000 to 12-31-2099.
So far I have only been able to get the discharge that goes above the threshold when I make each column a vector but I need all the information.
Once I have the date and the discharge I need to create a table to include in a figure.
Any ideas?
Thanks!
  2 Comments

Sign in to comment.

Answers (2)

Nishitha Ayyalapu
Nishitha Ayyalapu on 17 Oct 2013
Let "M" be the matrix with its 1st column as month, 2nd as Day, 3rd as year, 4th as discharge. Since "threshold" is only over discharge.
you can do this to find all the rows (Month,Day,Year,discharge) that are above threshold:
M(find(M(:,4)>0),:)
Hope this gives a good start to your problem

Azzi Abdelmalek
Azzi Abdelmalek on 17 Oct 2013
Edited: Azzi Abdelmalek on 17 Oct 2013
If M is your matrix
M=[1 1 1999 15;1 1 2000 25;11 15 2020 12 ;12 31 2099 26;12 14 2100 27]
N=zeros(size(M,1),6);
N(:,1:3)=M(:,[3 1 2]);
T=datenum(N);
d1=datenum('01-01-2000','mm-dd-yyyy');
d2=datenum('12-31-2099','mm-dd-yyyy');
idx=T>=d1 & T<=d2;
out=M(idx,:)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!