I have a a function $f(k)$ (calculated in Maple) which is huge and stored in a variable called 'sum' on my drive (with the help of 'save' command in Maple). Since the function is huge, Maple is unable to plot it and is taking endless time. Thus, I want to read the variable 'sum' into Matlab and plot it. I am unable to also just copy paste as the function is really big. I have searched around but am unable to find a solution. Can somebody help me out?

  • $\begingroup$ Is 'sum' an expression or a procedure? What sort of operations does it entail? (Just simple algebra, or are there e.g. transcendental functions?) And on an unrelated note, if you unprotect 'sum' in maple and reassign something to it that's not a procedure for summation, you're lucky if you still get useful answers from maple... $\endgroup$ – Erik P. Oct 27 '14 at 13:53
  • $\begingroup$ 'sum' is an expression and only has polynomial functions. $\endgroup$ – zynga Oct 27 '14 at 13:59

You can use the CodeGeneration package to do this. It allows to translate to different languages, being Matlab one of those.

A simple example here:

suma := sum(sin(n*x)/factorial(n), n = 0 .. 10);



with answer

cg3 = sin(x) + sin(0.2e1 * x) / 0.2e1 + sin(0.3e1 * x) / 0.6e1 + sin(0.4e1 * x) / 0.24e2 + sin(0.5e1 * x) / 0.120e3 + sin(0.6e1 * x) / 0.720e3 + sin(0.7e1 * x) / 0.5040e4 + sin(0.8e1 * x) / 0.40320e5 + sin(0.9e1 * x) / 0.362880e6 + sin(0.10e2 * x) / 0.3628800e7;

Off course, you can store this in a string and then write it to a text file, or translate a Maple procedure to a Matlab function.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.