Adding a .mex file to App Designer app

6 次查看(过去 30 天)
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?

回答(1 个)

Umar
Umar 2024-7-10
移动:Rik 2024-7-11
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 个评论
Rik
Rik 2024-7-11

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
Umar 2024-7-11
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by