Adding a .mex file to App Designer app
6 views (last 30 days)
Show older comments
I'd like to use Shuffle to shuffle the rows of a UITable.
https://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle
Hopefully it will keep the columns in a row together and can shuffle Var3 along with the numbers since it is a category ('L' or 'R')
I'll have to experiment unless someone knows how to call it:
will Y = Shuffle(X, Dim) only shuffle the Dim'ed column leaving the rest alone?
Uh oh separate question: will repose as another ask
If I have to use X(RANDPERM(LENGTH(X)) as the doc shows will that do it?
How?
0 Comments
Answers (1)
Umar
on 10 Jul 2024
Moved: Rik
on 11 Jul 2024
Hi Alessandro,
To address your first question, the Shuffle function in MATLAB typically shuffles the elements of an array along a specified dimension. In this case, using Y = Shuffle(X, Dim) would shuffle the elements along the specified dimension (Dim) while leaving the other dimensions untouched. Therefore, if you use Y = Shuffle(X, 1), it would shuffle the rows of your UITable while keeping the columns intact.
Regarding your second question about using RANDPERM(LENGTH(X)) as shown in the documentation, this approach is commonly used to shuffle the rows of an array or table. By applying this function to the indices of your table rows, you can achieve row shuffling effectively. To implement this, you can create a new table with shuffled rows by indexing X with RANDPERM(LENGTH(X)).
So, in order to shuffle the rows of your UITable while keeping columns together and shuffling a categorical variable along with numerical values, you can either use the Shuffle function with a specified dimension or apply RANDPERM(LENGTH(X)) to shuffle the rows directly. Experimenting with these methods will help you achieve the desired shuffling effect in your table. Please let me know if you have any further questions.
2 Comments
Rik
on 11 Jul 2024
Some minor notes:
- Since this is a function from the file exchange, there are no guarantees about this function. It might work, or only in a specific context, or not at all.
- Using length in this context is a terrible idea. Length will report the size of the largest dimension. You should always use numel or size instead, because that is what you mean. In this case you can even improve it: X(randperm(end))
Umar
on 11 Jul 2024
Hi @Rik,
Your notes are duly taken into consideration. It depends on OP if he intends to reports the size of the largest dimension or more precise representation of the array size.
Also, I do agree with the improvement idea utilizing X(randperm(end)) which can further enhance efficiency and accuracy, prevent bias in algorithms that rely on the order of input data and randomness leading to better generalization and prevent overfitting in machine learning models.
Good points.
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!