Questions tagged [matlab]

MATLAB is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks. Don’t use both the [matlab] and [octave] tags, unless the question is explicitly about the similarities or differences between the two. When using this tag, please mention the MATLAB release you're working with (e.g. R2017a).

MATLAB (Matrix Laboratory) is a high-level language and interactive programming environment for numerical computation and visualization, developed by MathWorks. MATLAB can be used when performing tasks such as signal processing and communications, image and video processing, computational finance, and computational biology. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend its core capabilities.

MATLAB is a cross-platform system developed since 1984. From the release of version 7.2 (R2006a) there has continued to be a biannual release cycle, with version "a" typically released in March/April and version "b" in September/October - based on the release history. For example R2017a and R2017b were the two releases in 2017.

MATLAB is a proprietary product of MathWorks. This means that, unlike open source languages, both programmers and users must own a valid software license in order to run MATLAB code.

There are several open source alternatives to MATLAB, in particular GNU Octave, which offers (mostly) bidirectional syntactic compatibility with MATLAB, Scilab, SciPy, and Julia.

Documentation

Informative links that show up quite often in answers##

  • Release notes for all versions.
  • MATLAB Central File Exchange: a repository of user-contributed MATLAB tools
  • MATLAB Add-Ons: Add-Ons for MATLAB
  • MATLAB Central blogs: usually updated weekly by a number of MathWorks employees
  • Undocumented MATLAB: "Charting MATLAB’s unsupported hidden underbelly"
  • MATLAB Answers: a collaborative environment for getting answers to questions about MathWorks products, similar to Stack Overflow
  • comp.soft-sys.matlab Usenet group: can be accessed online through Google Groups
  • MATLAB Cody™ is a place where you can go to find a variety of MATLAB-based coding challenges that will help to expand your understanding of MATLAB.
  • MATLAB ThingSpeak™ is an open data platform and API for the Internet of Things that enables you to collect, store, analyze, visualize, and act on data gathered directly from sensors or from other web sources. With ThingSpeak and its built-in MATLAB Analysis and MATLAB Visualizations apps, you can create custom trends and plots.
  • MATLAB Online: Online version of MATLAB (available to licensed users only). Octave Online is a free alternative based on the open source GNU Octave which is (pretty much) compatible with MATLAB.
  • MATLAB on Stack Overflow chat: Chat room for users of MATLAB and Octave
94593 questions
59
votes
4 answers

What is the closest thing MATLAB has to namespaces?

We have a lot of MATLAB code in my lab. The problem is there's really no way to organize it. Since all the functions have to be in the same folder to be called (or you have to add a bunch of folders to MATLAB's path environment variable), it seems…
rlbond
  • 65,341
  • 56
  • 178
  • 228
59
votes
4 answers

Generate a matrix containing all combinations of elements from n vectors (Cartesian product)

This question pops up quite often in one form or another (see for example here or here). So I thought I'd present it in a general form, and provide an answer which might serve for future reference. Given an arbitrary number n of vectors of possibly…
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
59
votes
9 answers

Performance Tradeoff - When is MATLAB better/slower than C/C++

I am aware that C/C++ is a lower-level language and generates relatively optimized machine code when we compare with any other high-level language. But I guess there is pretty much more than that, which is also evident from the practice. When I do…
Loves Probability
  • 929
  • 1
  • 9
  • 15
59
votes
11 answers

Finding the best trade-off point on a curve

Say I had some data, for which I want to fit a parametrized model over it. My goal is to find the best value for this model parameter. I'm doing model selection using a AIC/BIC/MDL type of criterion which rewards models with low error but also…
Amro
  • 123,847
  • 25
  • 243
  • 454
58
votes
9 answers

How to draw a crystal ball with two-color particles inside

I am just throwing an idea with possibility of closing. I need to draw a crystal ball in which red and blue particles randomly locate. I guess I have to go with photoshop, and even tried to make the ball in an image but as this is for research paper…
Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
57
votes
4 answers

How to iterate over a column vector in Matlab?

Possible Duplicate: How do I iterate through each element in an n-dimensional matrix in MATLAB? I have a column vector list which I would like to iterate like this: for elm in list //do something with elm How?
snakile
  • 52,936
  • 62
  • 169
  • 241
57
votes
10 answers

Calling MATLAB functions from python

Is it possible to run MATLAB functions from within Python? I search the internet, I could only find PyMat. The bad thing is the compiled version only supports Python2.2 and I am using 2.6. So I tried to download the source code, so I can compile it…
Hossein
  • 40,161
  • 57
  • 141
  • 175
57
votes
2 answers

Accelerating MATLAB code using GPUs?

AccelerEyes announced in December 2012 that it works with Mathworks on the GPU code and has discontinued its product Jacket for MATLAB: http://blog.accelereyes.com/blog/2012/12/12/exciting-updates-from-accelereyes/ Unfortunately they do not sell…
Stiefel
  • 2,677
  • 3
  • 31
  • 42
57
votes
5 answers

How to use SIFT algorithm to compute how similar two images are?

I have used the SIFT implementation of Andrea Vedaldi, to calculate the sift descriptors of two similar images (the second image is actually a zoomed in picture of the same object from a different angle). Now I am not able to figure out how to…
Lazer
  • 90,700
  • 113
  • 281
  • 364
56
votes
1 answer

What is the difference between .m and .mat files in MATLAB

When I traced my reference MATLAB script, I found files with the .mat extension. My questions are: What is the difference between .mat and .m files? How does one open files with the .mat extension?
user477670
  • 595
  • 1
  • 4
  • 5
56
votes
3 answers

Is indexing vectors in MATLAB inefficient?

Background My question is motivated by simple observations, which somewhat undermine the beliefs/assumptions often held/made by experienced MATLAB users: MATLAB is very well optimized when it comes to the built-in functions and the fundamental…
angainor
  • 11,760
  • 2
  • 36
  • 56
55
votes
4 answers

MATLAB - multiple return values from a function?

I'm writing 2 functions in matlab, an initialize function and a function to insert items into an array treating it like a doubly-linked list. However, my initialize function only returns "ans =" and the initialized array. How can I have it also set…
Nick
  • 551
  • 1
  • 4
  • 3
55
votes
4 answers

How do I detect if I'm running MATLAB or Octave?

I need to write code that should run equally well in Octave and on MATLAB. Problem is that it needs to do some GUI stuff, which MATLAB and Octave handle completely differently. Is there a way I can detect if I'm running MATLAB or Octave, in order to…
lindelof
  • 34,556
  • 31
  • 99
  • 140
53
votes
17 answers

Get rid of the white space around matlab figure's pdf output

I'd like to use PDF versions of my matlab plots in a LaTeX document. I'm saving the figures using the "saveas" command with the PDF option but I get huge white space around my plots in the pdf files. Is this normal? How can I get rid of it?…
mjbrown2
  • 533
  • 1
  • 4
  • 5
53
votes
7 answers

How to visualize a project structure in MATLAB?

I've come into ownership of several thousand lines of Matlab code, some as >900 line functions and a few directories full of function_name.m files. It's hard to figure out what everything is doing (or relating to) or figure out the dependencies. …
Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83