How to use Mupad MATLAB and Symbolic Math Toolbox to Develop and Analyze Financial Models

Learn the Secret

Get  our 2 Free Books

Get these now which land directly to their inbox.
Invalid email address
(Last Updated On: May 1, 2014)

How to use Mupad MATLAB and Symbolic Math Toolbox to Develop and Analyze Financial Models

These are two webinars that are proving to be vital to this algo development

Notes in the first webinar: (this is all part of the Matlab Symbolic Math Toolbox)

Solving symbolically is 1700% speed up numerically. Bond pricing example at 5:15

At 9:15 demos yield curves for bond pricing

18:05 demos the ability to import Excel data into a MU and M script with plots

30:48 demos the HUGE speed improvement using symbollic analysis vs numeric (i.e. back testing in finance)

Can this be done as fast as in R or Python?

Notes for Second webinar:

If you have followed me, the most successful quant/trader researcher that I know did exactly this at 2:31

4:29 explains how you gain the insight of the math vs using Financial Toolbox functions. You understand how the interaction of variables impact your results! You solve the problem once where you solve numerically with a slow iterative approach. So you basically have to start again with each new approach and recompute as well.

Many financial models are expressed analytically but symbolic math can be applied because of that. At 5:25, you can use these as building blocks to create custom models. At 7:25, he explains how easily you can go from symbols (Mupad) to numeric (Matlab interactive in the command line)

16:32 shows ability create a symbolic function using –> in Mupad language 16:39 explains how you can make general expression as functions with Mupad edit from within the Notepad editor. This a Mupad procedure or library (17:09)

18:37 shoes you how to plot in 3D. 19:26 shows animation. 20:47 shows how to add text regions to the Notepad or notebook document.

27:50 introduces solvers to optimize the equations which is part of the Optimization toolbox

32:59 displays the various Symbolic Math Toolbox libraries

2014-05-01 16_16_16-Using MATLAB and Symbolic Math Toolbox to Develop and Analyze Financial Models -


Don’t forget you can convert Mupad code into custom Matlab M functions which can be imported into both Simulink and Stateflow.

The R support to do this is VERY LIMITED as explained here:

It does not include the Notepad editor which Matlab has so it is light years ahead of R.

As for Python, all I could find is :

Eeek here are the open issues so this could be severely limited as compared to Matlab Symbolic Toolbox.

This also moves into C code generation:

Generate C Code from MATLAB Functions Using the Embedded MATLAB Subset

Some notes for this webinar:

Uses Kalman Filter to track an object, generate C, and apply the algorithm into Simulink for System level modelling.

At 6:07 he mentioned you can deploy even into Assembler.

At 8:15, he explains how handcoding from Matlab to C/C++ is not easy nor is it scalable. It is also introduces many errors. It minimizes the translation with advantages of visualization and other Matlab features. It is the Embedded Matlab workflow at 10:18.

I do believe this is old but renamed to the Matlab Coder so this webinar is old but there are equivalent functions to handle after Matlab 2009b

27:36 explains Kalman filter M function.

19:01 explains how Kalman Filter could be used to track something like price movements and estimate direction within this webinar.

32:39 explains how you can dynamically create C with elmex function. You can dynamically create C functions based what is in specific Matlab workspace structures. This generates a DLL automatically.

*** 36:59 he shows a trick to embed a Matlab M function C but turning off all functions not supported during the compile process. This includes visualizations function like figure. You declare the function extrinsic. Very cool!

41:32 shows a code generation to C. 43:00 shows entry point to the C file for Kalman. 45:07 proves that the C runs faster than the code generated MEX file.

49:00 described how to change input size of source data. How do you generate C code for this at 51:32? Use emlcoder.egs

51:10 explains how to use fixed point which is needed for Simulink models.  Use fi prefix or sfi signed fi)

1:00.900 explains globalfimath function

1:01:57 shows how to integrate the Kalman into a Simulink model


** You can use Video Viewer Simulink block to watch the animation of the Kalman filter function

Another webinar for HDL for FPGA deployment which is ultra lowest latency HFT deployment:

I am not going to explore at this point but will leave it to Mr FPGA


Join my FREE newsletter on my march learn how to do this algo development for financial models


NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!
This entry was posted in Matlab and tagged , , , , , , , on by .

About caustic

Hi i there My name is Bryan Downing. I am part of a company called QuantLabs.Net This is specifically a company with a high profile blog about technology, trading, financial, investment, quant, etc. It posts things on how to do job interviews with large companies like Morgan Stanley, Bloomberg, Citibank, and IBM. It also posts different unique tips and tricks on Java, C++, or C programming. It posts about different techniques in learning about Matlab and building models or strategies. There is a lot here if you are into venturing into the financial world like quant or technical analysis. It also discusses the future generation of trading and programming Specialties: C++, Java, C#, Matlab, quant, models, strategies, technical analysis, linux, windows P.S. I have been known to be the worst typist. Do not be offended by it as I like to bang stuff out and put priorty of what I do over typing. Maybe one day I can get a full time copy editor to help out. Do note I prefer videos as they are much easier to produce so check out my many video at