Reshape a matrix based on indices placed on another matrix
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi all,
I have a matrix called combinations and a vector whose dimension in 119x119.
The matrix combinations basically includes all the combinations of rows and columns of the desired matrix and the vector collects the values that I would like to be input. To make a practical example with a 9x9 matrix, say combination is made like this:
1	1
2	1
3	1
4	1
5	1
6	1
7	1
8	1
9	1
1	2
2	2
3   2
4	2
5   2
6   2
7   2
8	2
9	2
...
1  9
2  9
3  9
4  9
5  9
6  9
7  9
8  9
9  9
and vector of 81 elemnts is made like this:
NaN
0.78
0.34
...
0.56
...
NaN
where NaN is the 81th element and 0.56 is the element in correspondence of the couple 2-1 in the combination matrix. Notice that the elements of the main diagonal would be all NaNs.
Now what I would like to obtain is the 9x9 matrix with the values in the vector:
NaN 0.56 ...0.88
0.78 NaN ...0.99
...
0.34 ...    NaN
Thank you
0 件のコメント
採用された回答
  Voss
      
      
 2022 年 7 月 22 日
        v = rand(81,1);    % something like
v(1:10:end) = NaN; % your 81-by-1 vector
reshape(v,9,[])
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

