Cells and Cell vectors help?
1 回表示 (過去 30 日間)
古いコメントを表示
An assignment I have says...
An n-by-n square logical matrix can be represented by a cell vector of n elements where the kth element corresponds to the kth row of the matrix. Each element of the cell vector is a row vector of positive integers in increasing order reperesenting the column indexes of the logical true values in the given row of the matrix. All other elements in the given row of the ligical matrix are false. Write a function that takes such a cell vector as its only input and returns the corresponding square logical matrix. For example, such a cell vector representation of a 100-by-100 logical matrix with the only true elements at indexes (10,20) and (10,75) would have only one non-empty element of the 100-element cell vector at index 10. that element is the vector [20 75].
I am completely lost as to what the question is detailing/asking. Can somebody please explain what exactly this is saying?
1 件のコメント
darova
2020 年 4 月 3 日
As i understood the task correctly: the matrix consists of false elements except some
Sounds like sparse matrix. Do you have more explanations? Maybe a picture?
採用された回答
Matt J
2020 年 4 月 3 日
編集済み: Matt J
2020 年 4 月 3 日
So, as a smaller example, if n=4 and the input is this C={ [1 2] , [], [2 3 4], [] }, the output should be this,
A =
1 1 0 0
0 0 0 0
0 1 1 1
0 0 0 0
The contents of C{1} is [1,2] and this tells us that the first row has 1s in the first two elements and zeros elsewhere. Since C{3}=[2,3,4] the 3rd row has 1's in the second, third, and fourth elements and zeros elsewhere. Any row k for which C{k}=[] has only zeros in it.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!