• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

MATLAB help anyone?

man i wished i paid more attention in linear algebra... 😉


okay i have this matrix:

1 0 0 0 0
-1 1 0 0 0
-1 -1 1 0 0
-1 -1 -1 1 0
-1 -1 -1 -1 1

created by the code tril(-1*ones(5,5),-1)+eye(5)


i want to get to



1 0 0 0 1
-1 1 0 0 1
-1 -1 1 0 1
-1 -1 -1 1 1
-1 -1 -1 -1 1

anyone have an idea?
 
Why don't you just define the matrix you want, without calculating it, just type it in.
For a simple code, for a general n you can use:

[zeros(n,n-1),[ones(n-1,1);0]]+tril(-1*ones(n,n),-1)+eye(n)

Does it help?



 
Back
Top