Speeding up 2D Finite Difference Matrix
显示 更早的评论
I have two matrices B and D, where B is a
matrix and D is a
matrix defined as follows:
,where
is the
identity matrix and
denotes the Kronecker product of matrices P and Q. I am currently computing B as a sparse matrix as follows:
o = ones(n,1);
z = zeros(n,1);
D = spdiags([-o o z],-1:1,n,n);
D(1,1) = 0;
I = speye(n);
B1 = kron(I, D);
B2 = kron(D, I);
B = [B1;B2];
I know that
can be quickly computed using
[0; diff(x)]
I need to find a quick way of computing
and
in a similar manor. Currently my code is spending a signifigant amount of its time to compute
and
so I was wondering if anyone had some incite into computing this efficently.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!