The extraction and analysis of electricity consumption changing patterns are increasingly important, as they can guide in energy management and efficiency retrofitting. Consequently, it is necessary to extract the laws governing building electricity consumption characteristics. This method should be on an hour-scale and successfully applied online to various buildings. Under these conditions, the method should be as simple as possible to ensure excellent online applications. A matrix model method was developed based on the conventional K-nearest neighbour clustering algorithm, which introduced the concept of electricity intensity levels. This method used the slopes of the power consumption curve as the grading standard for the extraction and assessment of the electricity consumption laws. The validation results for seven different buildings with various functions and climate zones, including the mean absolute error, mean absolute percentage error, mean square error, root mean square error, and coefficient of variance, showed that this method met the aforementioned requirements. Moreover, this method can be used for power consumption prediction, which integrated a process of filtering historical data, leading to better accuracy and less data volume than that of other methods that use historical data for prediction. Practical application This paper proposed a matrix model method based on the conventional K-nearest-neighbour clustering algorithm, which introduced the concept of electricity intensity levels. This method was applied to various buildings online, which coupled the process of filtering historical data and flexible selectivity of models when used on different buildings. This method was used for assessing energy-saving potential, energy-saving retrofit priorities, and power consumption forecasting, which will benefit researchers and engineers.