matlab-plot u vs (log(1+tr{g}))

Status
Not open for further replies.

arushim

Newbie level 5
Joined
Aug 22, 2013
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
51
matlab
I want to plot u vs (log(1+tr{g}))..where u=0:100 and g=(inv((conj(k))' * k))...it is mentioned that tr{.} denotes trace of matrix..but the trace gives only 1 value..plot shows 1 constant value?
Plz explain what tr{.} actuall denotes here??
 

Yes, tr() is the trace of the matrix that is the sum of all the elements on the diagonal. Are you sure "k" is not function of "u" ?
 

OK, it means you have to calculate the trace of all the submatrix internal to your main matrix. For instance if your matrix is 5x5:
1 3 7 2 4
9 1 5 3 6
5 4 9 1 7
2 1 5 4 3
0 1 9 7 4

Then the submatrices are:

1...1 3...1 3 7...1 3 7 2...1 3 7 2 4
.....9 1...9 1 5...9 1 5 3...9 1 5 3 6
............5 4 9...5 4 9 1...5 4 9 1 7
......................2 1 5 4...2 1 5 4 3
...................................0 1 9 7 4

(I used the dot instead the space in order to align the figures)
From which the traces are 1, 2, 11, 15, 19

I wrote the following code (in scilab, very similar to matlab):

u=100; // this is the maximum index of the main matrix
k=grand(u,u,'def'); // Generates the main matrix (random numbers)

//-----------------------------------------------//

g=inv(conj(k))'*k; // Calculates the new matrix

for j=1:u,

M=g(1:j,1:j); // Extract the submatrix jxj (probably a more clever method exists)
z(j)=log10(1+trace(M)); // Calculate the trace
end

plot(z)


The first part is the generation of the matrix, just to see if the code works, of course you have to replace it with your real matrix.
 
Last edited:
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…