Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- epsilon = 0.45;
- t = -3.033;
- n = 100;
- I = ones(n,n);
- %// diagonal block 1
- DB1 = gallery('tridiag',ones(1,n-1),ones(1,n),ones(1,n-1));
- for k = 1:n
- DB1(k,k) = epsilon;
- end
- for k = 1:n-1
- DB1(k,k+1) = t*heaviside((-1)^(k+1));
- end
- for k = 2:n
- DB1(k,k-1) = t*heaviside((-1)^k);
- for k = 2:N
- LRG(:,:,k) = inv(R(:,:,k) - R2(:,:,k-1)*LRG(:,:,k-1)*R1(:,:,k-1));
- end
- epsilon = 0.45; t = -3.033;
- n = 100;
- DB1 = zeros(n); %initialize to 0
- %diagonal indices
- inds=sub2ind([n n],1:n,1:n);
- DB1(inds) = epsilon;
- %superdiagonal
- inds=sub2ind([n n],1:n-1,2:n);
- DB1(inds) = t*heaviside((-1).^(2:n));
- %subdiagonal
- inds=sub2ind([n n],2:n,1:n-1);
- DB1(inds) = t*heaviside((-1).^(2:n));
- DB1=sparse(DB1);
- DB1new=sparse([1:n 1:n-1 2:n],[1:n 2:n 1:n-1],...
- [epsilon*ones(1,n) t*heaviside((-1).^(2:n)) t*heaviside((-1).^(2:n))],n,n);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement