find maximum of data with some conditions
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
2 comentarios
Respuestas (1)
Neuropragmatist
el 4 de Sept. de 2019
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 comentarios
Neuropragmatist
el 6 de Sept. de 2019
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.
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!