find values in a matrix above a threshold

46 次查看(过去 30 天)
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 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-10-17
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!

请先登录,再进行评论。

回答(2 个)

Nishitha Ayyalapu
Nishitha Ayyalapu 2013-10-17
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 2013-10-17
编辑:Azzi Abdelmalek 2013-10-17
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,:)

Community Treasure Hunt

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

Start Hunting!

Translated by