Should I use object oriented programming in MATLAB?
Show older comments
I am designing a large Hybrid Electric Vehicle model and simulation in MATLAB (multi-order dynamic models of 10+ vehicle components, etc). The intention is to run Monte Carlo simulations with the simulation using the Parallel Computing Toolbox in MATLAB on a 200 node cluster. The simulation was originally implemented in Simulink, but needed to be rewritten in MATLAB M-code for cost/availability/performance/distributed computing reasons.
I have done a large portion of the design and implementation with MATLAB's object oriented programming constructs (and it is an extremely beautiful and elegant solution, if I may say so myself). However, I am concerned that there may be a performance hit for doing it this way, and would like to know what others think about this decision that have done similar things using MATLAB's OO constructs. I would like to hear what others think before I start the next phase of implementing such a system on the cluster (in the case that there is an overwhelming consensus to serialize the code for this application).
Thanks!
Accepted Answer
More Answers (1)
Jan
on 4 May 2011
Program time = programming time + debug time + run time
Your goal is to get the results as fast as possible considering your limited budget. While it is very easy to spend 400 hours for programming, it will be hard to gain 400 hours less runtime.
There are a lot of opinions about the efficiency of OO programming. But for a reliable decision the above formula is more scientific.
Another formula:
Program cost = programming time * HWP +
debug time * HWFP +
run tim * HMC
with:
HWP = Hourly wages for a programmer
HWFP = Hourly wages for a frustrated programmer
HMC = Hourly maintenance costs for the computers
4 Comments
Teja Muppirala
on 4 May 2011
Program time = programming time + debug time + run time. Your goal is to get the results as fast as possible considering your limited budget. While it is very easy to spend 400 hours for programming, it will be hard to gain 400 hours less runtime.
Yes Yes Yes! Your words are wise, Mr Simon. I wish more people would understand this concept.
Jan
on 4 May 2011
I admit, I did not claim to know the effects OO or not OO to the different times. The general idea is that tiny programms suffer from OO, and the larger and more complex a program is, the more advantages has OO. I personally would not prefer a specific programming style, if it increases to whole program time or costs.
BJ
on 4 May 2011
Mohamed Habib
on 8 Sep 2015
Edited: Mohamed Habib
on 8 Sep 2015
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!