Filter löschen
Filter löschen

Can anybody explain the interaction of Wilkinson and unique?

1 Ansicht (letzte 30 Tage)
I was working on one of the Cody questions, and encountered the wilkinson function. In working to solve the problem I was utilizing the unique() function on the wilkinson array, but the results that are returned are not what I would expect. This occurs while using the 'rows' option, not while just using unique.
x = wilkinson(9);
u = unique(x,'rows');
I would expect u to look something like a 9x3 array with 0, 1, and another integer identified in each row, but instead u comes out as a 9x9 array which is the vertical reflection of x.
Does anybody know why this result is generated?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Mai 2019
unique with the rows option does not proceed row by row to give you a list of unique values for the row. If it did do that it would have to return a cell array since the number of unique values could vary from row to row.
The rows option of unique tells you which rows are unique compared to the other rows.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by