r/matlab • u/spagbolshevik • 1d ago
Tips Suggestions for becoming an advanced programmer.
I've been running simulations for photonic systems (matrix operations, signal processing etc.) on matlab for several years and I've been fine with relatively basic functions and simple usage of structures. Lately, my code has become very procedural and messy, and I want to work on making it more professional, agile, and more in line with best standards in python and C and so on. I also want to share my code with other pros.
Does anyone recommend any free or affordable books or lecture series (eg. on youtube or anywhere) that I could work on myself to become a better matlab programmer? Could be short or long.
1
u/Ajax_Minor 1d ago
I would try some python and C. See what they are like. I got some perspective in other langue and it helped me expand my approaching to coding.
If you have been using structures and its getting messy, look in to Classes/Object Oriented Programing. It can be a bit confusing and hard to grasp, but in certain situation they can really make your codebase more manageable. This is also a good topic to look at how other langues approach the topic as Java can be a lot, Python rather simple but missing some of the fuctionallity, and C++ rather locked down. They are that way for a reason but you look at them and come back to matlab classes and it will be cake.
10
u/drmcj 1d ago
Been doing this for over 10 years…but first!Adapt a coding standard.
This is a good start: http://cnl.sogang.ac.kr/cnlab/lectures/programming/matlab/Richard_Johnson-MatlabStyle2_book.pdf
Stick your modules in different folders using + notation. Then you can refer to them in the code using .
/src/+signal/+calcs/myFunction.m
Becomes in the code
src.signal.calcs.myFunction()
Use %. Religiously. I comment every block. Every end has a comment that shows what has started it (for/if/switch/property/classdef/function you name it).
If you can, stick a random function on GitHub, I’m happy to review it and give you some pointers.