سؤال

I have a 8760x1 vector with the 1-hour average ambient temperature time series.

I want to calculate the weighted average temperature weighted by the percentage of operating hours at each temperature level.

What i thought is divide the temperature range with:

ceil(Tmax-Tmin)

and then use hist.

Are there any other suggestions? Thank you in advance.

هل كانت مفيدة؟

المحلول

mean(temperatures) should do it.

Since you have hourly measurements, the frequency of a given value will be reflecting the operating hours at that temperature level. A value that occurs frequently will therefore automatically have more weight in the average.

نصائح أخرى

Let's say you have two vectors that are the same length, one is the temperature (temp), and the other is the amount of time at that temperature (time_at_temp). The weighted average formula is this:

wt_avg_temp = sum(temp .* time_at_temp) / sum(time_at_temp);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top