Linear indexing in symmetric matrices

前端 未结 8 1167
遇见更好的自我
遇见更好的自我 2021-01-05 04:09

We can access matrices using linear indexing, which follows this pattern

0 1 2

3 4 5

6 7 8

It\'s easy to get the i,j coordinates for this cas

8条回答
  •  情话喂你
    2021-01-05 04:16

    Loop through your rows, keeping track of the offset of each one and the starting index for each:

    offset = 0;
    startOfRow = 0;
    for(i=0;i

    I don't know Matlab, so it's just pseudocode, but it should work. As horchler says, make sure your indexing is correct. I used i,j here as you had it in your example, but it just feels weird to me.

提交回复
热议问题