• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Teach Me MATLAB

pozz

Слава Україні
Forum Donor
Editor
Joined
May 21, 2019
Messages
4,036
Likes
6,828
I'd like to learn how to use this tool, how to run scripts, import/generate audio and analyze it.

Any good resources for folks with no engineering background, software or hardware?
 

robo

Member
Joined
Dec 21, 2020
Messages
18
Likes
20
Not quite what you're asking for, but have you looked at free alternatives like Jupyter Notebooks and NumPy? My wife is in an academic field that makes quite a lot of use of MATLAB and even within her field there's a real movement towards open source tools like Python to get the same stuff done in a way that's both more approachable and also free. I guess my point (if any) is that there's nothing really preventing them from using MATLAB (the uni pays for the licenses) but nevertheless they're moving away from it.
 

Josq

Member
Joined
Aug 11, 2020
Messages
69
Likes
79
Not quite what you're asking for, but have you looked at free alternatives like Jupyter Notebooks and NumPy?
Octave is the standard free alternative for MATLAB. Base MATLAB code can directly be used in Octave and vice versa.

So I suggest to download Octave and start reading the documentation. The first chapters contain the fundamentals and should not be too hard. Then you can move on to the more advanced/specific chapters. There is a brief chapter on audio processing.
 

ElNino

Addicted to Fun and Learning
Joined
Sep 26, 2019
Messages
558
Likes
727
I don't think anyone has really answered your question yet.

Since you don't have a particular background to start with, I'd suggest getting an intro to DSP book in MATLAB-style book. The one I had years ago is out of print and kind of obsolete so I can't recommend it in particular, but just Googling "Introduction to DSP with MATLAB" turns up at least three books, at least one of which is available for free download. I'd start with one of these. The book I had walked you through concrete tasks while also giving a high-level introduction to the math involved... I imagine the newer books are similar.

Also, if you can, I suggest getting the MATLAB Signal Processing Toolbox: https://www.mathworks.com/products/signal.html Apart from some important filter design functions (some of which have made it into free alternatives like Octave), it also comes with a Signal Analyzer application that's useful for exploration and decent documentation, as well as a bunch of more narrower-focused tools that haven't made it over to the free alternatives yet.
 

DonH56

Master Contributor
Technical Expert
Forum Donor
Joined
Mar 15, 2016
Messages
7,925
Likes
16,770
Location
Monument, CO
There are a bunch of books and many more YouTube videos but I do not have any of them so cannot say. Most of the audio texts cover the basics but focus more on speech processing. If you have no engineering background, why Matlab? What is your math, physics, or science background (level)? If you want an intro to Matlab, then the Wiley student book MatLab: An Introduction with Applications is probably a decent tutorial to get started. I have an ancient text that I think may be that one or similar that is useful for when I have not used Matlab for a while.

I agree with the suggestion to try Octave (Python-based) as a free version. Anaconda is a nice Python bundle but we (myself and others at home and at work) have had horrible problems trying to uninstall it (it does not work with some of our analysis programs and test scripts at work). I just downloaded the main code from the Python.org site (or whatever it is) and then used pip to get the other packages needed.

That said, Matlab some years ago finally released a version for DIY users that is reasonably priced. I owned the full version with a number of toolboxes for years after getting a student discount on the original purchase, but at some point the yearly upgrade went from a few hundred dollars to almost $2000 and I dropped it. I asked to get a student version for a class seminar I was giving and they sent me a free copy, kudos to Matlab! A few years later I noticed the "home" version and bought it. Have barely used it, alas, as work has been all-consuming the past few years.
 

scott wurcer

Major Contributor
Audio Luminary
Technical Expert
Joined
Apr 24, 2019
Messages
1,501
Likes
2,822
I'd like to learn how to use this tool, how to run scripts, import/generate audio and analyze it.

Any good resources for folks with no engineering background, software or hardware?

I'm not sure any of the solutions would be turnkey enough with no software background. I prefer Python over Octave though both are wanting out of the box for audio. I have managed to write a bunch of useful Python scripts doing basically what you want.
 
Last edited:

amirm

Founder/Admin
Staff Member
CFO (Chief Fun Officer)
Joined
Feb 13, 2016
Messages
44,753
Likes
242,118
Location
Seattle Area
I forget the package name but a year ago Matlab released a nice toolkit for audio analysis with graph building and such. May be worth looking that up.

In general, I say google for an example program that does what you want to do (or baseline of it). Get that working and then play with it. Matlab programs tend to be small since the libraries do bulk of the work. And then just watch some intro to Matlab and you should be good.
 
OP
pozz

pozz

Слава Україні
Forum Donor
Editor
Joined
May 21, 2019
Messages
4,036
Likes
6,828
Thanks everyone. I should have specified my goals. I want to calculate Rnonlin, which is a perceptual correlation metric for distortion. There is existing work on this, but there might be some incompatibility with open source programs given that it was developed in MATLAB. They aren't scripts (.m files) in some cases either. So I can't port them over to Octave, which I was initially planning to use. Maybe this is less of a problem than I make it out to be though. Just seems like a heavy obstacle from a layman's perspective.

Aside from that, I'd also like to use the already-developed audio processing toolboxes in MATLAB and get comfortable enough with them that I can test the audio I work with while mixing. My tools for that up to this point have been ears, meters and spectrum analyzers, but there's only so far you can get with those.

@DonH56 I am really a newbie. I have what you can call a reading knowledge rather than a practical knowledge of science. Education was in literature, philosophy, social science and so forth. I have not done scripting, I can handle basic statistics, and math is not scary but I am far from understanding the components of an acoustic wave equation, for example. The embarassing thing is that I've read enough to understand the history, perspectives and experiments in psychoacoustics, as well as their upshot, but there are large portions of the work that are completely inaccessible for me because it is mathematically oriented and drops descriptive and explanatory language.

I'm typing all this on my phone. I'll check back tomorrow and get a bit more specific after I've looked at the suggested resources.
 

JohnYang1997

Master Contributor
Technical Expert
Audio Company
Joined
Dec 28, 2018
Messages
7,175
Likes
18,301
Location
China
You can find everything here.
https://www.mathworks.com/help/matlab/ref/audioread.html
For more intuitive tutorials, there are many videos on YouTube. You can basically find everything you need.
eg
for sample rate conversion

But you have to know how to fix things when you break something. The fundamentals. If not matlab isn't for you I'm afraid. REW and an analogue in analogue out dsp board from adi is probably more suitable.
 
Last edited:

hmscott

Addicted to Fun and Learning
Joined
May 17, 2020
Messages
604
Likes
493
Here's a little more info on the Audio Toolbox from Matlab:

Help Center - MATLAB & Simulink (mathworks.com)

I think I have copies of Matlab 6.x(?) somewhere for MacOS and Windows, probably not compatible with the Audio Toolbox kit... :(

Audio Toolbox Documentation (mathworks.com)

DSP, Deep Learning, Functions apply to Audio
https://www.mathworks.com/help/dsp/index.html
https://www.mathworks.com/help/deeplearning/index.html

There are also File exchange titles that look interesting
Audio System Toolbox - File Exchange - MATLAB Central (mathworks.com)
File Exchange - MATLAB Central (mathworks.com)
 
Last edited:
OP
pozz

pozz

Слава Україні
Forum Donor
Editor
Joined
May 21, 2019
Messages
4,036
Likes
6,828
Sorry I left things hanging here. It's my first time off work this year and I've taken a big step back from my usual day-to-day (in which ASR is a constant).

My actual MATLAB-related questions are very basic at the moment. I'll have to devote time to going through the resources everyone has posted. The only other big obstacle is understanding the details of the underlying calculations, which even now is non-trivial and parts will definitely be beyond my current abilities, although, again, I think I understand enough of the context and research that I can at least ask good questions or specify unknowns.

I'll post as I learn the material. I hope it will be enough to do the enthusiast thing by using ready-made tools and looking up sources as I need. When something does break (as @JohnYang1997 said), I also hope it doesn't mean that I need to take a degree in the sciences to make it work.
 

q3cpma

Major Contributor
Joined
May 22, 2019
Messages
3,060
Likes
4,420
Location
France
Another "vote" for Python, free software really is the future in this case. Especially since you either know Python, so it's easy as pie to go forward, or you don't and you'll learn a language way more useful than Matlab for more general tasks. A bit like comparing Avisynth and the Python based Vapoursynth.
Though I personally prefer Tcl (or Lua, or Scheme) to Python, as it's way more elegant than what can be called "the C++ of scripting languages"; but numpy and co. are only for Python, so no real choice (tcllib does have a matrix package, though, but no scipy or scikit-learn equivalent). See http://lists.suckless.org/dev/2002/33777.html for a good laugh about Python bloat.
 

SoundAndMotion

Active Member
Joined
Mar 23, 2016
Messages
144
Likes
111
Location
Germany
I'm not sure any of the solutions would be turnkey enough with no software background.
Although I find all the posts here offer valuable ideas, I believe what @scott wurcer says may be correct. Along an artificial 1-D continuum scale of: programmer <-> user
I think the ideas offered are better suited toward the programmer half of the scale than the user end.

I think @pozz indicates that (I paraphrased in italics):
I'd like to learn how to use this tool, how to run scripts, import/generate audio and analyze it.
I want to calculate (something)(for which there's code) [snip]...
I'd also like to use (existing tools), (so) I can test (stuff, beyond what I can do with) ears, meters and spectrum analyzers.
I hope it will be enough to do the enthusiast thing by using ready-made tools and looking up sources as I need.
@pozz If you already have some MATLAB code to do what you want, I (and others) can help you to get it going. Or if @scott wurcer has what you need in python, perhaps he can help. I (and others) may also be able to help you with the other stuff you want to do, when the need/desire arises.

I do not want to discourage or turn you away from learning to code yourself! It may well be that's the best path for you. It was for me! You will gain a lot of independence and get exactly what you want, not having to settle for what others have done. But if you've never programmed, it may be a bigger task than you think.
If you do want to take this path, I'll give you yet another $0.02 opinion on the python/jupyter/scipy vs. MATLAB vs. GNU Octave choice later. One question: if you'll use this for work, is the $5k or so for MATLAB plus a couple toolboxes (e.g. signal processing &audio) an issue? There are academic and home versions for much less, if appropriate.... and then there's free stuff.

Also,
The only other big obstacle is understanding the details of the underlying calculations, which even now is non-trivial and parts will definitely be beyond my current abilities...
I might be able to help here too, but understanding your goal along a different artificial continuum: verbal/conceptual <-> mathematically complete
would help.
 

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,730
Likes
6,050
Location
US East
@pozz Just to let you know, I tried installing Simon Durbridge's "Rnonlin_calc" app into my MATLAB (after struggling through to get Malcolm Slaney's Auditory Toolbox to work), and it needed 2 add-on toolboxes that I don't have. Sorry :(

MATLAB.PNG
 

Foxenfurter

Active Member
Joined
Mar 5, 2020
Messages
129
Likes
157
Location
London
If you are interested in learning python, I found that Jupyter Notebooks provided an easy experience. The main advantage is that you can write your script in a block (they call it a cell) at a time - i.e. a few related lines of code. This massively helps when debugging as you can easily isolate the block that is failing and correct and re-run until it is working, provided you keep the block size small of course.

It is worth the time to do a few tutorials that should include using external libraries and writing your own function calls. Once you learn how to do this with one language learning other languages becomes easier too.

There are a ton of useful resources to get you going.
 
OP
pozz

pozz

Слава Україні
Forum Donor
Editor
Joined
May 21, 2019
Messages
4,036
Likes
6,828
@pozz Just to let you know, I tried installing Simon Durbridge's "Rnonlin_calc" app into my MATLAB (after struggling through to get Malcolm Slaney's Auditory Toolbox to work), and it needed 2 add-on toolboxes that I don't have. Sorry :(

View attachment 103157
You found all the pieces:) I got the license for both of those and found Slaney's Auditory toolbox for Durbridge's app. I even found the latter's abandoned blog and contacted him for help (no reply yet).

The major obstacle was that I had no idea how to get Slaney's Toolbox to gel with Durbridge's Rnonlin. I figured I had to take a whole lot of steps back and learn the basics.
 
Top Bottom