Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Replace -> with = after Optimize[]' topicStudent Support Forum > General > "Replace -> with = after Optimize[]"

Next Comment >Help | Reply To Topic
Author Comment/Response
04/28/10 09:54am

Using Optimize[] from Optimize.m I get a list of equations which look like
newoptimizationvariable -> oldexpression

I want to use these results in Matlab, so I use CForm[]. But of course this creates something like
Rule(newoptimisationvariable, oldexpression)

So i want to replace "->" with "=".

Using StringReplace doesnt work right. When i use StringReplace with a variable of my expression like
opt = Optimize[expression]
StringReplace[opt, "->" -> "="]
Mathematica complains, that there is no string in Position 1.

So I tried to copy&paste the optimized expression into
StringReplace["paste_here", "->" -> "="]

This seemed to work right, but when i then use
CForm[] it results in some weird expressions with lots of slashes inside like
o48 = \!\(1\/12\)
instead of
o48 = 1/12

URL: ,

Subject (listing for 'Replace -> with = after Optimize[]')
Author Date Posted
Replace -> with = after Optimize[] ndrs 04/28/10 09:54am
Re: Replace -> with = after Optimize[] yehuda ben-s... 05/02/10 10:41am
Re: Re: Replace -> with = after Optimize[] ndrs 05/03/10 04:04am
Next Comment >Help | Reply To Topic