Adding Matrices of Different Sizes

I am calculation Cooling Loads.
I need to find Total Cooling Load (Qtotal)
Total Cooling Load is technically the sum of my first floor (QF1), second floor (QF2), sensible heat gain by infiltration (Qis) and latent heat gain by infiltration (Qil).
So,
Qtotal = QF1+QF2+Qis+Qil;
But due to hours of occupation,
QF1 is a 1:12 matrix
QF2 is a 1:8 matrix
Qis and Qil are both 1:24 matrix
ANy help on how i can go about calculating this. Thanks.

1 个评论

The 'hours of occupation' comment leads me to believe that each vector contains samples of a measurment across time but those time stamps aren't aligned. If that's the case, hopefully you have the timestamps for each vector in which case you can interpolate using interp1(). If the sampling rates are fixed but unequal between vectors, you could also look into resample(). Ultimately, it might be beneficial to organize the data into a timetable with 1 column of timstamps and the other columns would contain your measurements.

请先登录,再进行评论。

 采纳的回答

Star Strider
Star Strider 2019-10-2
I would creat all the vectors initially as zeros(1,24), then fill in the elements corresponding to the hours of occupation in QF1 and QF2. Then, all the matrices align and the addition proceeds.

6 个评论

this is what i think is the best course of action. i am just unsure about how to proceed.
% ZONE COOLING LOAD (Actual)
QZ1 = zeros(1,24);
QZ2 = zeros(1,24);
QZ3 = zeros(1,24);
QZ4 = zeros(1,24);
QZ5 = zeros(1,24);
QZ6 = zeros(1,24);
QZ7 = zeros(1,24);
QR = zeros(1,24);
QZ1 = Qz1(1,8:20);
QZ2 = Qz2(1,8:20);
QZ3 = Qz3(1,8:18);
QZ4 = Qz4(1,8:18);
QZ5 = Qz5(1,8:18);
QZ6 = Qz6(1,8:18);
QZ7 = Qz7(1,8:18);
QR = Q_R(1,8:18);
% FLOOR COOLING LOAD
QF1 = QZ1+QZ2;
QF2 = QZ3+QZ4+QZ5+QZ6+QZ7+QR;
% TOTAL COOLING LOAD
Qtotal = QF1+QF2+Qis+Qil;
but i stil get matrix dimensions must agree.
Correct idea, slightly in error as to the addressing.
Try this:
QZ1 = zeros(1,24); % Preallocate
. . .
Qz1 = rand(1,13); % Create Test Data
. . .
QZ1(8:20) = Qz1 % Assign
The preallocation is the correct approach. You then need to index the destination vector (‘QZ1’ in this example) with the values of ‘Qz1’ (and the others as appropriate). I am not quite certain what ‘Qz1’ and the others look like, however if they are similar in structure to my test vectors, this should work.
It did exactly what i needed. Thank you very much!
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

产品

版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by