如何将Matlab的点运算符转换为R? [英] How to translate Matlab's dot operators into R?
本文介绍了如何将Matlab的点运算符转换为R?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Matlab具有一组点运算符,例如.*
,./
,.^
.这些算子中的每一个都由一个点和一个正常的代数算子组成.
我想将它们翻译成R:
Matlab has a set of dot operators, such as .*
, ./
, .^
. Each of these operators consists of a dot and a normal algebraic operator.
I would like to translate these into R:
col = round(r0 + (j/k) * lambda .* cos(pi/6))+1;
ro = 700 - round(s0 - (j/k) * sin(phi)./cos(pi/6))
col = min(col):1:max(col)
ro = min(ro):1:max(ro)
请帮助
推荐答案
您可以将代码行转换为字符并使用gsub
You could convert your lines of code to characters and use gsub
a <- "col = round(r0 + (j/k) * lambda .* cos(pi/6))+1;"
a <- gsub("\\.","",a)
您可以将其包装在函数中.
which you could wrap in a function.
所以,这是一个可以实现的功能,
So, here's a function to do it,
DotOut <- function(x) {
gsub("\\.","",x)
}
然后您可以在应用功能之一中使用此功能.
You could then use this function in one of the apply functions.
这篇关于如何将Matlab的点运算符转换为R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文