MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by Paulo Silva on 23 Feb 2011

Don't be shy, what was your matlab learning curve, how many years or months, what were the difficulties to begin with.

I think that the answers would be most valuable for new users, maybe you can also tell us the tricks that allowed you to master some parts or all matlab.

Now it's your turn...

Answer by proecsm on 24 Feb 2011

I first encountered Matlab in the 90's working for a large aerospace company. I didn't have the opportunity to use it much then, but was always interested in severing the ties from Excel for 'real' calculations. In 2005, I was working in a test lab which used Labview and when version 8 (I think) came out, it included their version called mathscript and I thought cool, now I can learn about programming a 'matlab'-like language.

When I entered grad school, I knew I needed a math application and for whatever reason I chose (ahem) Maple. I made it most of the way through, until a class required developing models in Simulink. So, I got the student version and dived in.

I would say my learning curve was not terribly long for basic stuff, but I continue to learn new stuff. Last fall, for the first time, I was a 'lurker' on the contest page and found it really interesting. Hopefully I can enter the spring contest!

I keep my Matlab skills up to date by doing Project Euler problems and answering what questions I can here and on CSSM

Answer by Paulo Silva on 24 Feb 2011

My story, the first time I saw Matlab was almost 10 years ago, we used matlab in school but not very often, all we did was simple things like making simulink models and see the output, lately in Digital Control we used matlab and simulink more, only here I saw the true power of matlab and people using functions that no one told me to use in school. Now I'm working on my Thesis about the control of the Inverted Pendulum and the knowledge I found here is always useful, every day something new comes up after a question and I love to try to help others because it's a great way to learn.

My tricks are, watching experts answering questions and analyse their code, viewing matworks webinars and the blogs, and most of the time try to use new matlab functions just for fun.

My difficulties at first were related to not knowing which function to use to solve a problem, now they are with the use of functions like arrayfun, cellfun, bsxfun, etc. Their are great but I still find them hard to use, the for loops are used too often.

Right now I should be an expert but I'm not, I still find hard to solve many simple problems, still learning.

Show 2 older comments

Jan Simon on 25 Feb 2011

I'm still waiting for the click for ACCUMARRAY. Every time I get the opinion, that this function might match my problem, I have to dig in the docs.

K E on 26 Jan 2012

Me too. I always end up just looping through the bins because it is quicker to program than accumarray with histc. Plus I understand what it's doing.

Answer by Matt Fig on 24 Feb 2011

I first saw MATLAB in 1997 (v4.?) when taking a linear algebra class to satisfy my Math major. The class used this awful book. I only used MATLAB a few times, and hated it. I couldn't figure out how to do anything, and the command line reminded me of DOS.

7 years later, while doing summer internship graduate work at the lab where I now work, I was forced to deal again with MATLAB. The physicist who was my mentor was a MATLAB fanatic, and insisted that I spend the first 2 weeks of my internship in front of the computer doing nothing but playing around with MATLAB (Incidentally, he is the one who taught me to use a double letter for a loop variable). I ordered this book and just went through it. Soon I was loving MATLAB and ready to do my summer work. I also ended up learning how to write GUIs (using global variables, string callbacks and switchyard programming, yikes!). The result of all that summer's work is on the FEX.

When I returned to school in the fall I had to take a class which required the use of MATLAB. Of course I was exited to learn even more, which I did.

Since then I have written many M-Files, GUIs and even taught MATLAB to others. I am an unpaid MATLAB evangelist, both on and off the job.

Walter Roberson on 24 Feb 2011

You are unpaid on the job?? Or you are just not paid for being an Matlab Evangelist?

Answer by David Young on 24 Feb 2011

I learnt to program originally in Fortran. (My first programs, as an undergraduate, were on punched cards.) After various other languages I spent a lot of time with the amazing, wonderful and controversial Pop-11. Most people here would love Pop-11, I suspect, but it never had the integrated numerical or graphical capabilities of MATLAB, though I did push it some way in that direction.

In 1999 a colleague at my university persuaded me that MATLAB would have advantages for teaching computer vision - not least, a larger user community - so we switched and I started learning it. It took me quite a while to get the hang of some of the powerful general ideas - notably the different array indexing modes - but once I did I started using it for both teaching and research, and I haven't looked back. I still enjoy those moments when I understand a feature for the first time and realise how powerful it is - bsxfun, regexp and accumarray are good examples.

Paulo, I can't suggest shortcuts to help beginners. I think it's all about reading the documentation carefully, looking at examples, and above all experimenting with little pieces of code until you're certain you know what each element does. It can take a lot of time and perseverance. My main advice to programming students is: write functions from the start, and keep them small.

Paulo Silva on 24 Feb 2011

Hi David, your story and the other ones were interesting to read, the main purpose of the Question was to show new users that it takes years to master matlab.

I forgot to mention that I started programming in a casio graphic calculator, it was almost all about the Label and Goto function, I spent weeks doing programs and games, it was fun and my first computer was bought in the year 2000, it was one old pentium 133Mhz, those were the good old days.

Walter Roberson on 24 Feb 2011

Years to master matlab... For that you have to distinguish between Matlab the programming language and Matlab the extensive scientific library. The programming language is not so different from other programming languages. The scientific library though, is extensive and very few people indeed have the skills and time to get to know the entire science library (complete with toolboxes) and then to figure out the most efficient (or shortest command) to do each task at hand. I don't expect *anyone* to understand all the tricks of the science libraries.

Answer by Walter Roberson on 24 Feb 2011

Although we've had Matlab at my workplace for some time, until relatively recently I was working on matters it was not appropriate for. I moved on to my current project about the middle of July 2007, and started learning Matlab because that's what the original project implementor had happened to start with. Everything I know about using Matlab, I've picked up in the last 3 years and 7 months.

I am, though, not new to scientific programming: I've been doing a mix of scientific programming and computer/network/security administration for over 25 years, using a variety of languages.

Answer by John D'Errico on 24 Feb 2011

I actually had a copy of MATLAB for the Mac, a version that I think ran on a 512k Mac or so. (Mid 1980's.) This was back in the infancy of MATLAB. Actually though, at the time I was still using APL for most of my work, even some Fortran then. I'd written many complete toolboxes by then for APL - splines, linear algebra, optimization, random variate generation, statistical tolerancing, etc.

With that background around 1988, I then found myself attached to the ColorSense program at Kodak. That group was using MATLAB to do their work, so I picked it up in earnest then. (The MATLAB version at the time was 3.5.) We developed a large library of tools for modeling, as well as developing a consistent documentation style for the group tools that all were using. Every Friday afternoon our group would meet in a peer review session to decide which tools would be admitted to the group library.

Since that time, I've written a few dozen toolboxes for various applications in MATLAB, at least a few of which are available on the FEX.

Answer by Jan Simon on 24 Feb 2011

I've started programming in Sinclair Basic on a ZX81 in the 80th. It was an exhausting challenge to write a check player or a analog clock with just 1kB and 64*44 pixels. In the university I've learned how to program larger computers in C and Fortan.

The lab I've worked in 1998 used Matlab 4.2 to solve tin batch processing jobs, and my co-worker told me that it is very slow, because you have to cast each command inside an EVAL command and this dynamic creation of variables ruins the efficiency. The first Matlab-program I saw used an EVAL in **each** line! After reading the Getting Started chapters of the doc (yes, I've read them all!) I found out, that it was very easy to improve this program by simply deleting the EVALs.

The next step was to learn the unique idea of Matlab and use arrays instead of the elementwise processing. A very important milestone was learning how to use CUMSUM for indexing in a post of Bruno in CSSM (Thanks Bruno! I owe you 200 hours processing time).

After some time, I reached the magic limit of 100.000 lines of code and any further changes and additions lead to the unavoidable clash, because it is impossible for a person to keep the full overview in such a number of interdependencies and different versions. Because there were urgent demands for reliability in the field I've worked in, I needed new programming paradigmas:

- An exhaustive version history for each M-file
- Unit-tests for all fundamental functions
- Automatic testing of the high-level routines and control of the results for a set of testdata. A large program
**cannot**be 100% correct. But it can and must be checked, that it works inside the specified parameters. - Exhaustive documentation in each M-file and for the whole program - this includes automatic updates of the docs, if some input arguments changes their behaviour.

The more features these programs had, the longer the execution times was. Matlab's PROFILEr is so kind to tell the programmers, where the bottlenecks are and I started to replace them by tiny and easy C-mex functions. A lot of discussions in CSSM helped me to improve the internal data representation of my code, e.g. accessing the arrays columnwise, such that contiguos blocks of memory are processed. I've learned to use shared data copies from the C-Mex functions submitted by James Tursa (Thanks James! It's your merit, that I can stil run my programs on a 512MB Pentium-M laptop.).

Today I want to pay back te knowledge I've obtained from CSSM. Efficient programs reduce the CO2 production, therefore it is worth to invest some energy in efficient programming techniques. And I admit that the interaction with the Matlab community means a lot of fun for me.

Paulo Silva on 24 Feb 2011

Hi Jan, nice story and tips, can you please provide us with the link for:

'CUMSUM for indexing in a post of Bruno in CSSM', I can't find it, thank you

Answer by Jiro Doke on 25 Feb 2011

I would say I've been using MATLAB consistently for about 11 years, since my first year in graduate school. In undergraduate, I may have used it a few times for a homework set. I say "I may have" because I don't quite remember anything about it except that I had an installation disk.

My experience in programming prior to MATLAB was some BASIC from childhood and a little bit of Pascal from a couple of courses in undergraduate. My graduate advisor was a heavy MATLAB user, and my initial experience with it involved deciphering his MATLAB code for doing some plots. At the same time, I was taking a controls course which required me to learn Simulink.

I remember struggling a lot for the first few months. I didn't hate it because I kind of liked programming. But I was definitely struggling. Having done some stuff in Maple before, understanding how to plot a function in MATLAB was very difficult. It took a little while for me to grasp the idea that I have to define the vector before I can plot it.

x = 0:0.1:10; <-- this was hard to grasp at first plot(x, sin(x));

Once I overcame that initial hurdle, I started to really enjoy it. I began experimenting with MATLAB code and reading the documentation and tutorials. But I didn’t really “get” the power of MATLAB until my advisor showed me this code for a simple peak-finding algorithm (of course there are more sophisticated, more robust methods):

% Sample data t = 0:0.01:10; x = sin(2*t) - 3*cos(3.8*t);

dx = diff(x); % get differences between consecutive points pkIDX = (dx(1:end-1) >= 0) & (dx(2:end) < 0); % look for slope changes pkIDX = [dx(1)<0, pkIDX, dx(end)>=0]; % deal with edges plot(t, x, t(pkIDX), x(pkIDX), 'ro');

This was such an eye-opener. The fact that I could find peaks without having to loop through the vector really made me appreciate the power of MATLAB. Read a post about it here.

After a few months into using MATLAB, I discovered CSSM (MATLAB newsgroup). I started posting questions left and right, and I learned a lot from the forum. Soon after, I started to answer some questions, and reading CSSM became my daily ritual.

About a year after the start, I saw one of my lab mates creating a graphical application in MATLAB. I was completely blown away by what I was seeing, and I started to play around with GUIDE and then some programmatic GUI building. That’s how my passion for GUIs came about. Because of my research background (biomechanics), I had a need for creating animations of my biomechanics experiments. That allowed me to learn everything that I currently know about handle graphics. Having no formal training in programming, I found MATLAB to be a great tool for making me feel like a programmer. I love that a lot! With the new and improved capabilities in object oriented programming in MATLAB, I’m starting to do a lot more OO programming lately.

I think the key to becoming proficient in MATLAB is to be curious and to try things out. The documentation is rich with examples, so read up on it and experiment. And use resources like MATLAB Answers and CSSM to keep sharpening your MATLAB skills.

Paulo Silva on 25 Feb 2011

Hi Jiro, your story is 100% what I wanted when I created the Question :) thanks for telling your story and providing us with tips and the code example.

+1 vote, for you and the others that told their own story

Jiro Doke on 25 Feb 2011

@Paulo: Thanks for your comment. While I consider myself an advanced MATLAB user, I truly appreciate the struggles people go through when they are learning MATLAB for the first time. In my role, I get to introduce MATLAB to a lot of new users, and I hear many interesting comments. I love thinking about how we can make it easier for people to start using MATLAB.

Answer by John Petersen on 13 Mar 2014

I was introduced to Matlab by Herm Schutten way back in 1988 while just starting graduate school. I quickly grew to love it. A few years later I was trying to decide what programming language to be "good" at. I was thinking about C and Fortran. But then I decided I'd rather program in Matlab. So I decided that would be my forte. I still found it necessary to program in C and Fortran and even other languages, but my experience with Matlab did not hinder me at all. As people grew to know I knew Matlab I became more of a goto guy for that and got to do more and more with it. I've moved around a bit (7 times). For each of these job changes I have made I have insisted on having Matlab. I've seen quite a bit of evolution with Matlab, but it's mostly been welcomed. I'm glad I made the good decision to stick to Matlab. It has been a great asset for me. Thankyou Mathworks!

Answer by Andreas Goser on 27 Jul 2011

I graduated end of 1994 and knew a symbolic math software (I do not name here :-) ) from my time at the university.

When I started my career as a researcher, I used this tool write a certain simulation. This however was mostly numerical math and thus the simulation ran for multiple hours. I asked around (not much internet research those days...) and somebody suggested to try MATLAB. As the simulation took just a couple of minutes, my professor an I were very excited.

Consequently, I joined a MathWorks (it was a distributor to that time) seminar and learned about Simulink, Real-Time Workshop and other magic things. Since then, I created multiple applications for student labs and research application of all kinds.

I remember vividly the excitement when MATLAB 5.0 (Release 8) came out, beacuse it was the first release on a CD!

Answer by dpb on 5 Jul 2013

It's a long time coming, but... :) Hadn't seen this owing to not having switched from cs-sm.

Is interesting to hear the stories/experiences--after reading the others to date I appear to be even older -- my first copy of Matlab was V3 altho after a search I can't seem to locate it any longer to find the actual date. It must have been sometime in mid- to late-80s, though. By that time I had 10 years of programming (virtually all FORTRAN from IBM 1620 at uni to Philco 2000 followed by CDC-6600/Cyber-7600 doing support and development of large (by the standards of the day's capacities--even the 7600 had only 64k 60-bit core memory and up to 512k-words of secondary memory) nuclear design codes for commercial power applications for a reactor vendor followed by almost another 10 year of consulting work where the variety was wide but still almost all FORTRAN but by then on VAXen/DEC10 w/ a tiny bit of IBM 370 thrown in just to be able to curse JCL.

At the time and the impetus for purchasing Matlab was I had been doing failure modes and effects analyses on reactor control systems which entail reading every schematic (of which there were several thousand) and by hand, writing down the action of each and every controlled element and aux output contact given a loss of power to that particular element. After that was compiled into a database, it was then necessary to aggregate all elements on each power supply at and below each branch point and then propagate a hypothetical failure at that point thru the entire rest of the system and ultimately assess the state of the plant and safety implications of that state. The real pressure of the job was that it was verified by actually going to the plant in question and pulling a fuse at a given point and observing state and comparing to the database.

I was desperately looking for ways to implement the logic to be able to automate this process and link controlled components to their circuits and them, in turn to the power node hierarchy. I had not succumbed to the PC craze until the AT and when employer offered and interest-free payroll deduction plan, I bought (for a mere $4000+) an AST 8(!)-MHz/AT w/ 1 (whole!) MB of memory. I had at that time also been involved with a robotics effort that was implemented in Forth and was strongly influenced by the power of "defining words"--a mechanism by which one could build runtime code that was dependent on the data supplied. I worked on the problem down that vein for a while before deciding it wasn't what was looking for and then a PC/AT Smalltalk was released. Again, it had promise but didn't have the facilities was really looking for.

So, I then heard of Matlab and thought the array syntax and similarity of the language to Fortran that I knew much better than Smalltalk might be a solution. In the end, that also never totally panned out altho I was able to do some small-scale problems with it I was again unable to implement what I really wanted which was essentially a reactor controls simulator w/ power loss response capability. Twenty/thirty some years later I think I now actually have learned enough to now know how one might implement such! :) (I will note that all of the above efforts were not done as part of the paying "day job" but were moonlighting efforts on top of actually plodding along on the actual analyses by hand so it wasn't quite like I was getting uninterrupted periods to work on it. In the consulting game we were competing against several other vendors for a dwindling amount of business and I was hoping if I could build a toolset I could underbid the competition as well as not have to work 16-hr days to meet deliverables.)

Meanwhile, doing that I began to appreciate what Matlab could do for other computational areas and continued to use it off and on as individual projects arose where it was aptly suited; primarily the graphics that was well ahead of anything else available to me at the time other than the Tek workstations or drawing Calcomp paper plots from the VAX w/ DISSPLA.

After that point my directions again switched to supporting mostly the fossil utilities rather than nuclear and were directed mostly to controls and instrumentation and development of new techniques for pulverized coal flow. In those, visualization and signal processing were key areas.

As for learning, it's all been a very long-term case of osmosis and as another said while he had 3+ yr of Matlab experience the 25+ of programming was probably key in the ability to simply switch implementation languages as opposed to starting programming from the beginning.

I recall my first FORTRAN on the Philco in '68 was a pretty feeble piece of code albeit it did get the job done (eventually). I'm sure if I had had no more experience when first installed Matlab as did when punched the first card deck I'd have been at least as inept... :)

dpb on 5 Jul 2013

No. Never! :) (At least until there's an equivalent newsreader interface for the Answers forum)

I resolved I'd try to stick it out to get to a rating of 40 but the interface is still so klunky that I lose patience before I can get very far. Over the 4th traffic at cs-sm has been particularly slow and I've been laid up a little so been looking for something to piddle at and that's had me here a little more than otherwise would have been...

I did see a couple of interesting rearrangement problems I spent some time on but I guess the posters must have had the holiday long weekend as nothing back as far as a response as yet to see how I fared in giving useful solutions...

Plus, I did promise TMW as part of their generous offer to comp me a copy of R12b as retiree that I'd at least give the forum a fair shot so I'm trying...and occasionally make suggestions/bug reports on various aspects. :)

Answer by dpb on 6 Jul 2013

Indeed...some have been very handy in an off-list mentoring situation last month w/ a Indian student studying in Sweden while working as an (apprently unpaid) summer intern in Berlin. Wouldn'ta happened when I was his age...

Not sure how much more TMW would want me to let out of the bag here...I do still have intentions of looking at some that I haven't gotten to yet with respect to some ag production areas on the farm that I thought might be an area for another direction for toolboxes to head...but, w/ the severe drought I'll have to get some previous data to even get started as we had essentially no production of winter wheat this year.

Jan Simon on 31 Jul 2013

@dpb: I tend to delete this answer, because I do not see a relation to the question also. Is this a joke? Could anybody know, what kind of "off-list mentoring situation" you mean and is it of public interest?

If you are not sure, how much more TMW would want you to let out of the bag, ask someone how can decide this, because the forum users cannot answer this mysterious question.

Answer by Cedric Wannaz on 23 Jul 2013

Edited by Cedric Wannaz on 23 Jul 2013

I started using MATLAB in 95, but I didn’t get serious about it until 97. Being more of a "low level" programming and electronics engineering guy (uP/uC systems) at that time, I had worked with several assembly languages, C, Pascal, and Fortran, prior to really starting with scientific computing. From 97 on, I have been using essentially MATLAB/C for engineering projects, Sysquake for building highly interactive demonstrators (MATLAB syntax "compatible" and really worth the try), Mathematica for physics and mathematics, and Python for data pre/post processing and for "gluing things together". I slowly shifted towards MATLAB as this is where my projects lead me. Now I am essentially mixing MALTAB, Python, and ArcGIS, even though people who know me are likely to call me a MATLAB evangelist ;-)

Cheers,

Cedric

Answer by MUNNANGI ANIRUDH on 22 Jan 2014

I learnt about a software called matlab back in 2009 and i thought it was "just" one of the regular tools. I now know how wrong i was back then, as matlab is such a wondrous tool that has changed my "just" an engineering experience to the ultimate engineering experience.

I saw matlab as Matlab 7.0 and in those days it used to come in a compact disk ( :P ). Now we see Matlab R2013a/b and you need a high memory flash drive or hard drive to keep it.

The journey from Matlab 7.0 to R2013a/b has been quite an enriching one. It has been equally inspiring. I was an undergraduate student back then and i was the only one who knew Matlab and was called "The Matlab Guy". I have dedicated a lot of time in helping others with matlab and inspiring them about the software and its benefits. Now after four and half years, i am in different country but definitely in the same position. I am still the best in matlab. Here many know about it though, but i have got something called experience and thus i use it to solve bigger problems and challenges.

It all drops down to the dedication and interest one has towards the awesome tool which keeps us going ahead and ahead day by day, script by script, run by run. I believe everyone does the same and uphold the true value of education which is to share knowledge ! Just in our case, the knowledge to be shared is "how to apply knowledge ;)"

Enjoy Matlab !

Answer by Marco on 14 Mar 2014

I knew I would need to learn a programming language to get scientific data (images) analyzed, something I always wanted to do. I made an intensive study on what programming language might suite my needs best - not beeing a genius in mathematics and abstract thinking at all, and quickly being frightened by a syntax which contains more cryptic " void ^¨.:=;(?{[@ " signs than readable code. That was 13 years ago. That time I decide to learn MATLAB - because of its philosophy to be as an interpreted language suitable to be used for rapid prototyping and - other than many of the free of purchasing cost alternatives - coming with a lot of professional documentation, something I decided to pay for with my little student budget. Furthermore I got the message that images or stacks of images are matrices and many loop programming could be avoided in the code by the matrix orientated syntax of MATLAB. Code appeared intuitively readable. Unfortunately other (also very interesting) laboratory work on other topics never left enough free time and no justification to do so during official work time to really go for any programming. Until some 9 month ago! I repeated my search for the proper language and came to the same conclusion as years ago, mainly (in comparison to very hot alternatives) because of the documentation aspect, and because MATLAB seems to be able to call functions from the hot alternatives / connect well to other function libraries. The documentation is very important for me as an autodidact not having any teacher around - besides the internet community, and having a rapid prototyping environment as the control center which can connect and incorporate other function libaries and other languages code if needed, sounded great. And my frist baby is born now - 9 month later. I can simulate my current laboratory experiment in silico and derive information from my simulation parameters for understanding what the hell is going on in my unordinary drifting experiment. And I fullfilled a dream of mine: I am finally programming some image analysis - officially at work! Well, I encounter more and more that I just have to get used to cryptic syntax. The @ is almost not frightening me anymore, I am too much busy with still getting more comfortable with the different meaning of {} () and [].

## 1 Comment

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/1899#comment_27742

See also: http://www.mathworks.com/matlabcentral/answers/12531-how-did-you-learn-matlab