Convert R code into Matlab

老子叫甜甜 提交于 2019-12-13 07:33:29

问题


I need to write in Matlab this portion of the package "tensor" which is written in R. Unfortunately I am not used to R code style.

where A=matrix(sample(0:1, 2 * 3, replace = TRUE), 2, 3) here the code in 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])
  )

Thank you in advance for your help!


回答1:


alongA is undefined; the R code is incomplete. could you provide a working sample?



来源:https://stackoverflow.com/questions/46457760/convert-r-code-into-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!