Operations on portions of matrices to the end of the matrices.
1 次查看(过去 30 天)
显示 更早的评论
First, let me start off by thanking this matlab answers community for its tremendous support for those of us new to the mathematical programming world. I've already been helped immensely by many great minds.
I'm running across an issue at the moment that I cannot wrap my head around and could use some help. I have two matrices, K & Beta. K is always 'n' rows by 4 columns. Beta is also always 'n' rows but can possibly have more columns than K.
The problem is to do mathematical operations on portions of the K and Beta matrices and combine the results in a K_structure matrix. Essentially I want to do the following:
K_structure = Beta(1:4,:)'*K(1:4,:)*Beta(1:4,:) + Beta(5:8,:)'*K(5:8,:)*Beta(5:8,:) + Beta(9:12,:)'*K(9:12,:)*Beta(9:12,:) + ...
So, the first 4 rows of Beta' times the first 4 rows of K times the first 4 rows of Beta then plus the next 4 rows of Beta' times the next 4 rows of K times the next 4 rows of Beta + ... and so on until the end of Beta and K are reached. Based on the program the end row is a multiple of 4 (i.e. 4, 8, 12, 16, etc.)
Any help would be terrific.
0 个评论
采纳的回答
更多回答(1 个)
Honglei Chen
2013-3-11
编辑:Honglei Chen
2013-3-12
Why not just use a for loop?
Let's say your K is 12 rows, so
Niteration = 12/4;
K_structure = zeros(size(Beta,2));
for m = 1:Niteration
idx = (1:4)+(m-1)*4;
K_structure = K_structure + Beta(idx,:)'*K(idx,:)*Beta(idx,:);
end
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!