将 R 代码转换为 Matlab [英] Convert R code into Matlab

查看:61
本文介绍了将 R 代码转换为 Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)这里是 R 中的代码:

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])
  )

预先感谢您的帮助!

推荐答案

alongA is undefined;R 代码不完整.你能提供一个工作样本吗?

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

这篇关于将 R 代码转换为 Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆