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
53
votes
21 answers

What is MATLAB good for? Why is it so used by universities? When is it better than Python?

I've been recently asked to learn some MATLAB basics for a class. What does make it so cool for researchers and people that works in university? I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python…
Andrea Ambu
  • 38,188
  • 14
  • 54
  • 77
53
votes
7 answers

Matrix from Python to MATLAB

I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? Thanks!
mlkyway3
52
votes
4 answers

Using fourier analysis for time series prediction

For data that is known to have seasonal, or daily patterns I'd like to use fourier analysis be used to make predictions. After running fft on time series data, I obtain coefficients. How can I use these coefficients for prediction? I believe FFT…
BBSysDyn
  • 4,389
  • 8
  • 48
  • 63
52
votes
6 answers

How to create a new figure in MATLAB?

Usually when I plot in MATLAB, it always draws on the same figure. How do I make it draw in a new figure? I know it is pretty elementary, but I'm not finding it using Google Search.
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
52
votes
5 answers

Fitting largest circle in free area in image with distributed particle

I am working on images to detect and fit the largest possible circle in any of the free areas of an image containing distributed particles: (able to detect the location of particle). One direction is to define a circle touching any 3-point…
T50740
  • 539
  • 4
  • 6
52
votes
7 answers

How to initialize an array of structs in MATLAB?

How can I preallocate an array of structs in MATLAB? I want to preallocate "a" in this example so that it does not resize several times. a = [] for i = 1:100 a(i).x = i; end
Mohammad Moghimi
  • 4,636
  • 14
  • 50
  • 76
52
votes
4 answers

.m files as MATLAB/Octave for Sublime Text

Sublime sees .m files as Objective C files. I've been given a bunch of MATLAB/Octave files to work with using Octave, all with .m extensions. If I change the extensions to .matlab, then Sublime will recognize them and format them correctly, but…
scharfmn
  • 3,561
  • 7
  • 38
  • 53
51
votes
2 answers

Inhibit Matlab Window Focus Stealing

Is there a way to tell Matlab not to steal window focus (from an external editor) such as Emacs) upon graphical commands such as figure and plot. This would increase my productivity a lot because I often want to continue code development during data…
Nordlöw
  • 11,838
  • 10
  • 52
  • 99
51
votes
3 answers

MATLAB - How to zoom subplots together?

I have multiple subplots in one figure. The X axis of each plot is the same variable (time). The Y axis on each plot is different (both in what it represents and the magnitude of the data). I would like a way to zoom in on the time scale on all…
Miebster
  • 2,365
  • 4
  • 21
  • 27
51
votes
4 answers

Get the indices of the n largest elements in a matrix

Suppose I have the following matrix: 01 02 03 06 03 05 07 02 13 10 11 12 32 01 08 03 And I want the indices of the top 5 elements (in this case, 32, 13, 12, 11, 10). What is the cleanest way to do this in MATLAB?
Vlad the Impala
  • 15,572
  • 16
  • 81
  • 124
50
votes
5 answers

How to normalize a signal to zero mean and unit variance?

I am new to MATLAB and I am trying to built a voice morphing system using MATLAB. So I would like to know how to normalize a signal to zero mean and unit variance using MATLAB?
geeti
  • 513
  • 1
  • 4
  • 6
50
votes
4 answers

Random numbers that add to 100: Matlab

[I'm splitting a population number into different matrices and want to test my code using random numbers for now.] Quick question guys and thanks for your help in advance - If I use; 100*rand(9,1) What is the best way to make these 9 numbers add…
Tetra
  • 747
  • 2
  • 9
  • 15
50
votes
12 answers

ternary operator in matlab

is there a way of typing for if like: var = (cond) ? true : false; or do we have to use this format? if (cond) true else false end
50
votes
4 answers

Understanding Matlab FFT example

I am new to matlab and FFT and want to understand the Matlab FFT example. For now I have two main questions: 1) Why does the x-axis (frequency) end at 500? How do I know that there aren't more frequencies or are they just ignored? 2) How do I know…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
49
votes
9 answers

How to generate all pairs from two vectors in MATLAB using vectorised code?

More than once now I have needed to generate all possible pairs of two vectors in MATLAB which I do with for loops which take up a fair few lines of code i.e. vec1 = 1:4; vec2 = 1:3; i = 0; pairs = zeros([4*3 2]); for val1 = vec1 for val2 =…
Brendan
  • 18,771
  • 17
  • 83
  • 114