Group Abstract Group Abstract

Message Boards Message Boards

Export transfer function to Matlab: force string with negative exponents

Posted 4 years ago

I calculated some transfer functions in Mathematica analytically and would now like to import them into Matlab for controller optimization. The problem is now, that these transfer functions contain numerous delay times, which are expressed as "exp(-s*Tdel)". I use the following command to generate a string from the transfer functions:

StringReplace[ToString[Gref, InputForm], {"E^" -> "exp", "*^" -> "e"}]

Then I copy the string into a Matlab script. This works fine as long as I don't have any time delays, however, if I add the time delays I face the problem that Matlab can't handle negative delay times (Tdel being negative). Mathematica on the other hand tries everything to get rid of the negative exponents and constantly changes these expressions from ... * exp(-s Tdel) to 1/exp(s Tdel). Is there a proper way to get my equations from Mathematica into Matlab?

I tried replacing s wiith (-y) and replacing it back in Matlab, however, some of the time delays stayed negative, ending up positive then. I'm looking for a way to force Mathematica, to explicitly use only negative (or only positive) exponents.

POSTED BY: X Y
POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard