Cells and Cell vectors help?

2 次查看(过去 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
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by