Cells and Cell vectors help?

2 visualizaciones (últimos 30 días)
James Metz
James Metz el 3 de Abr. de 2020
Comentada: darova el 3 de Abr. de 2020
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 comentario
darova
darova el 3 de Abr. de 2020
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?

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 3 de Abr. de 2020
Editada: Matt J el 3 de Abr. de 2020
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.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by