find maximum of data with some conditions
18 ビュー (過去 30 日間)
古いコメントを表示
I had one year load data of a transformer hourly time interval, so load(365*24, 24) matrix. I want to find out the maximum of each day and that day load(1,24) in each season of the year.
but condition is:
lets say in season 1(March-May)
max load is 500 on 23rd May and its loading duration in some range[450 500] or nearby maximum load duration is only for 4 time slots. but at that season 1 their may be second max is 480 such that that day loading duration is range of [430 480] or nearby maximum load duration is for 10 time slots of that day. In this case I will choose second maximum.
similarly find for all season max load of that day.
thanks
回答 (1 件)
Neuropragmatist
2019 年 9 月 4 日
I really don't understand your question, how are the data arranged? Can you give us an example piece of data?
It sounds like you might want to look at the second output of max (or nanmax) which is the index of the maximum value:
Hope this helps,
M.
2 件のコメント
Neuropragmatist
2019 年 9 月 6 日
OK,
Lets make some example data and try some things. Lets just make data for 10 days (so 10 rows) with 24 hours per day (so 24 columns):
dat = rand(10,24)*500; % just some dummy/example data
If I understand correctly you want to find the maximum load for each day, you can do that like this:
max_load = max(dat,[],2);
Now the next part is not very clear - you want to know how many hours each day the load was above a certain threshold? Do these hours have to be contiguous (in one connected block)? If not, you can use something like this:
load_threshold = 400;
hours_above_threshold = sum(dat>load_threshold,2)
If you want the load threshold to change for each day you can also make load_threshold a vector:
load_threshold = max_load-50;
hours_above_threshold_minus_50 = sum(dat>load_threshold,2)
If the hours have to be contiguous you will have to find the values above the threshold you want, find the maximum value, find contiguous regions using bwlabel:
then find which region corresponds to the maximum, then get the size of that region to get contiguous hours above the threshold around the maximum.
Hope this helps,
M.
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!