diff diags.m @ 412:5eb312dfe2ab feature/diags

Add full matrix equivalent of spdiags
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 07 Feb 2017 13:58:03 +0100
parents
children 0b87863cb29c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/diags.m	Tue Feb 07 13:58:03 2017 +0100
@@ -0,0 +1,9 @@
+function A = diags(B,d,m,n)
+    assert(size(B,1) == m);
+
+    A = repmat(B(:,1)*0, [1, n]);
+
+    for i = 1:size(B,2)
+        A(:,d(i)+ (1:m)) = A(:,d(i)+ (1:m)) + diag(B(:,i));
+    end
+end
\ No newline at end of file