From 1c8400ab93e5073f7ddc53b09a1aaebd2df70dab Mon Sep 17 00:00:00 2001 From: Evgeny Metelkin Date: Mon, 15 Jul 2024 11:50:27 +0300 Subject: [PATCH] convert ln to log for matlab --- src/matlab-export/expression.js | 3 +++ test/core/expression.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/matlab-export/expression.js b/src/matlab-export/expression.js index ea36893f..31500902 100644 --- a/src/matlab-export/expression.js +++ b/src/matlab-export/expression.js @@ -36,6 +36,9 @@ Expression.prototype.toMatlabString = function(substituteByDefinitions = true) { if (node.type==='FunctionNode' && node.fn.name==='log2') { return `(log(${node.args[0].toString(options)})/log(2))`; } + if (node.type==='FunctionNode' && node.fn.name==='ln') { + return `log(${node.args[0].toString(options)})`; + } if (node.type==='SymbolNode' && node.name === 't') { return 'time'; } diff --git a/test/core/expression.js b/test/core/expression.js index 91426338..9485ec6a 100644 --- a/test/core/expression.js +++ b/test/core/expression.js @@ -162,4 +162,8 @@ describe('Expession exports', () => { let expr = Expression.fromString('exp(-kel*t)'); expect(expr.toMatlabString()).to.be.equal('exp(-kel * time)'); }); + it('toMatlabString() for "ln(x)"', () => { + let expr = Expression.fromString('ln(x)'); + expect(expr.toMatlabString()).to.be.equal('log(x)'); + }); });