【问题标题】:Convert R code into Matlab将 R 代码转换为 Matlab
【发布时间】:2017-09-27 21:49:28
【问题描述】:

我需要在 Matlab 中编写包“张量”的这一部分,它是用 R 编写的。不幸的是,我不习惯 R 代码风格。

A=matrix(sample(0:1, 2 * 3, replace = TRUE), 2, 3) 这里是R中的代码:

  A <- as.array(A)
  dimA <- dim(A)
  dnA <- dimnames(A)      

  seqA <- seq(along=dimA)
  allA <- length(seqA) == length(alongA)
  permA <- c(seqA[-alongA], alongA)
  if (!all(seqA == permA))
    A <- aperm(A, permA)
  dim(A) <- c(
    if (allA) 1 else prod(dimA[-alongA]),
    prod(dimA[alongA])
  )

提前感谢您的帮助!

【问题讨论】:

    标签: r matlab tensor


    【解决方案1】:

    alongA 未定义; R代码不完整。你能提供一个工作样本吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-06
      • 2011-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多