【问题标题】:Assigning randomly selecting and removing rows from a 2d matrix分配从二维矩阵中随机选择和删除行
【发布时间】:2012-11-24 14:31:48
【问题描述】:

我有一个包含 stimlui 的 35x2 矩阵,用于单词记忆实验。每次运行我的程序时,我都需要随机抽取 16 个单元格,以便实验总是不同的。我已经设法使用 datasample() 创建一个 8x2 矩阵来做到这一点,但是我需要将它们从 35x2 中删除,以确保它们不会在两次试验的第二次中被重新选择。当单元格坐标已知时,我知道如何删除单元格;但不是每次随机选择它们时。我们将不胜感激地接受任何建议。

谢谢

凯莉

【问题讨论】:

    标签: matlab variables random row


    【解决方案1】:

    Datasample 返回它选择的索引。考虑一下这个

      m = rand(35,2);             % // test matrix
      [s i ] = datasample(m,8,1); % // s are the samples, i are their indices
       m(i,:) = [];               % // elimination of selected samples
    

    【讨论】:

    • 亲爱的 Acorbe,感谢您的帮助
    • @KellyMurphy,不客气。您可能要考虑接受答案。
    猜你喜欢
    • 2018-07-10
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    • 2018-11-11
    相关资源
    最近更新 更多