Using kronecker product and elementwise multiplication
4 次查看(过去 30 天)
显示 更早的评论
Dear all,
I have the matrix
der=[2 5 ;3 4]
OMEGA=kron(eye(2),der);
Suppose that now I have the 1 by 2 vector y
y=[3 4];
I want to multiply the first element of y with the first 'der' which is with OMEGA and the second element of y with the second 'der' which is within OMEGA.
Any ideas? Thanks in advance
0 个评论
采纳的回答
James Tursa
2017-9-26
编辑:James Tursa
2017-9-26
yy = repmat(y,size(der,1),1);
result = bsxfun(@times,OMEGA,yy(:));
or in later versions of MATLAB
result = OMEGA .* yy(:);
Should work even if der is not square.
0 个评论
更多回答(1 个)
Andrei Bobrov
2017-9-26
编辑:Andrei Bobrov
2017-9-26
der=[2 5 ;3 4]
OMEGA=kron(eye(2),der)
y=[3 4]
out = OMEGA.*kron(y,ones(1,2))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!