Description Usage Arguments Details Author(s) Examples
By this function one can plot and draw any kind of LR, RL and L fuzzy numbers.
1 |
M |
A LR, RL or L fuzzy number |
Left.fun |
The left-shape function which usually defined before using LRFN.plot (see examples in bellow) |
Right.fun |
The right-shape function which usually defined before using LRFN.plot (see examples in bellow) |
... |
Any argument of curve() function, such as xlim, ylim, lwd, lty, col, add and ... is acceptable for this function |
Befor useing "LRFN.plot" function, first define the left shape and the right shape functions of LR fuzzy number. Also, xlim argument must (is better to) be defined for the first fuzzy number.
Abbas Parchami
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # Example 1:
# First introduce left-side and right-side functions of LR fuzzy number
Left.fun = function(x) { (1-x^2)*(x>=0)}
Right.fun = function(x) { (exp(-x))*(x>=0)}
A = LR(20, 12, 10)
LRFN.plot(A, xlim=c(0,60), col=1)
LRFN.plot(A, lty=2, lwd=3, col=2, add=TRUE)
# Example 2:
# for first LR fuzzy number:
Left.fun = function(x) { (1-x^2)*(x>=0)}
Right.fun = function(x) { (exp(-x))*(x>=0)}
LRFN.plot( LR(17,5,3), xlim=c(5,40), lwd=2, lty=2, col=2)
# for second LR fuzzy number:
Left.fun = function(x) { (1/(1+x^2))*(x>=0)}
Right.fun = function(x) { (1/(1+(2*abs(x))))*(x>=0)}
LRFN.plot( RL(20,2,3), lwd=2, col=1, add=TRUE)
# for third LR fuzzy number:
Left.fun = function(x) { (1-x)*(x>=0)}
LRFN.plot( L(30,15,5), lwd=2, lty=3, col=4, add=TRUE)
legend( "topright", c("LR(17, 5, 3)", "RL(20, 2, 3)", "L(30, 15, 5)"), col = c(2, 1, 4)
, text.col = 1, lwd = c(2,2,2), lty = c(2, 1, 3) )
## The function is currently defined as
function (M, Left.fun = NULL, Right.fun = NULL, ...)
{
if ( messages(M) != 1 ) { return( messages(M) ) }
m = M[1]
m_l = M[2]
m_r = M[3]
x <- NULL
if ( M[4] == 0 ) { y = function(x) Left.fun((m-x)/m_l) * (x<=m) + Right.fun((x-m)/m_r) * (m<x) }
else if (M[4]==1) { y = function(x) Right.fun((m-x)/m_l) * (x<=m) + Left.fun((x-m)/m_r) * (m<x) }
else if (M[4]==0.5) { y = function(x) Left.fun((m-x)/m_l) * (x<=m) + Left.fun((x-m)/m_r) * (m<x)}
else{return(noquote(paste0("The fourth element of each LR fuzzy number must be 0 or 0.5 or 1!")))}
return( curve(y(x) * (0<=y(x) & y(x)<=1), ...) )
}
|
Attaching package: 'Calculator.LR.FNs'
The following object is masked from 'package:base':
sign
function (M, Left.fun = NULL, Right.fun = NULL, ...)
{
if (messages(M) != 1) {
return(messages(M))
}
m = M[1]
m_l = M[2]
m_r = M[3]
x <- NULL
if (M[4] == 0) {
y = function(x) Left.fun((m - x)/m_l) * (x <= m) + Right.fun((x -
m)/m_r) * (m < x)
}
else if (M[4] == 1) {
y = function(x) Right.fun((m - x)/m_l) * (x <= m) + Left.fun((x -
m)/m_r) * (m < x)
}
else if (M[4] == 0.5) {
y = function(x) Left.fun((m - x)/m_l) * (x <= m) + Left.fun((x -
m)/m_r) * (m < x)
}
else {
return(noquote(paste0("The fourth element of each LR fuzzy number must be 0 or 0.5 or 1!")))
}
return(curve(y(x) * (0 <= y(x) & y(x) <= 1), ...))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.