Cells and Cell vectors help?

2 vues (au cours des 30 derniers jours)
James Metz
James Metz le 3 Avr 2020
Commenté : darova le 3 Avr 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 commentaire
darova
darova le 3 Avr 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?

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 3 Avr 2020
Modifié(e) : Matt J le 3 Avr 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.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by