【问题标题】:Can you explain the following Octave/MatLab code for me?您能为我解释以下 Octave/MatLab 代码吗?
【发布时间】:2016-10-27 09:48:17
【问题描述】:
load train.txt train(186,:)=[]; 
train = train(:,[1 2 4]); 
load test.txt test = test(:,[1 2 4]); 
p1 = clrscr(test(:,1), bayes_cls(train, test(:,2:end), @classpdf_indep, 0.1)); 
p1 = [p1 clserr(test(:,1), bayes_cls(train, test(:,2:end), @classpdf_dep, 0.1))]; 
p1 = [p1 clserr(test(:,1), bayes_cls(train, test(:,2:end), @classpdf_parzen, 0.1))] 
  1. 名为train.txt 的文本文件作为矩阵加载到八度音程中。而且,我们从该矩阵中选择 186 行。那么=[] 发生了什么?

  2. 我们从矩阵 train 中选择所有行,仅包含第 1,2 和 4 列,并将其分配给旧矩阵。本质上,我们正在清除一些数据。我说的对吗?

  3. 我们正在将 test.txt 加载到 octave 并选择第 1,2 和 4 列的所有行。对吗?

那么,#4,5 和 6 行是怎么回事?

【问题讨论】:

    标签: matlab matrix octave


    【解决方案1】:

    也许您应该问编写代码的老师?尽管如此:

    1. 在train.txt 文件中保存了一个矩阵“train”。它已加载并删除了 186. 行。
    2. 你是对的
    3. 您是对的,但我认为您犯了复制和粘贴错误并遗漏了一个“;”和换行
    4. 很难说不知道 clscr、clserr、bayes_cls 是函数还是数组(我猜它们是函数,在这种情况下,它是对带有第一列测试的 clrscr 的调用、对bayes 的调用等等)和结果填充到p1中

    我在这一点上保释。这些都是基本的功能/方法,你应该学习matlab语言的基本概念。这就像问“请解释一下 y = f(x) = sin(x) + x^3”

    【讨论】:

      猜你喜欢
      • 2023-04-02
      • 1970-01-01
      • 2011-07-12
      • 1970-01-01
      • 2012-04-09
      • 2022-06-11
      • 2019-02-01
      • 1970-01-01
      • 2016-11-27
      相关资源
      最近更新 更多