find values in a matrix above a threshold
59 views (last 30 days)
Show older comments
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
Azzi Abdelmalek
on 17 Oct 2013
Maria commented
Sorry I am new at matlab and I am having a hard time applying your code to my case. Where do you specify what the threshold is?
My matrix "data" has daily discharge data from 01-01-2000 to 12-31-2099 organized in four columns: month, day, year, discharge. I need to find the discharge that goes above the threshold "Flood_stage" and create a table with the discharge and the date that goes above the threshold (in my case is a number saved as Flood_stage) only, I don't need the values under the threshold.
Thanks!
Answers (2)
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
0 Comments
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,:)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!