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
49
votes
4 answers

How do I visualize a matrix with colors and values displayed?

I want to create images like this from a double precision matrix using MATLAB. Sample image: http://twitpic.com/2xs943
Piji
  • 685
  • 1
  • 8
  • 13
49
votes
4 answers

Find location of current m-file in MATLAB

I'm working on my MATLAB code in a number of different locations, and it would really help if I could make the code aware of its location on the computer. I think there is a function that gives me exactly this information, but I can't remember what…
Jordi
  • 5,846
  • 10
  • 40
  • 41
49
votes
1 answer

How to use numpy.void type

I loaded a MATLAB .mat file via scipy.io.loadmat and it gave me a list of numpy.void objects. What are they, how can they be used and where can I get some reference documentation on them?
Felix
  • 3,351
  • 6
  • 40
  • 68
48
votes
11 answers

Random points inside a parallelogram

I have a 4 side convex Polygon defined by 4 points in 2D, and I want to be able to generate random points inside it. If it really simplifies the problem, I can limit the polygon to a parallelogram, but a more general answer is preferred. Generating…
Andres
  • 1,875
  • 1
  • 19
  • 28
48
votes
9 answers

How do I do multiple assignment in MATLAB?

Here's an example of what I'm looking for: >> foo = [88, 12]; >> [x, y] = foo; I'd expect something like this afterwards: >> x x = 88 >> y y = 12 But instead I get errors like: ??? Too many output arguments. I thought deal() might do…
Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83
48
votes
6 answers

How to normalize a vector in MATLAB efficiently? Any related built-in function?

I normalize a vector V in MATLAB as following: normalized_V = V/norm(V); however, is it the most elegant (efficient) way to normalize a vector in MATLAB?
Kamran Bigdely
  • 7,946
  • 18
  • 66
  • 86
47
votes
6 answers

Algorithm to generate random 2D polygon

I'm not sure how to approach this problem. I'm not sure how complex a task it is. My aim is to have an algorithm that generates any polygon. My only requirement is that the polygon is not complex (i.e. sides do not intersect). I'm using Matlab for…
s5s
  • 11,159
  • 21
  • 74
  • 121
47
votes
3 answers

How to reduce the borders around subplots in matlab?

In matlab, an inordinate amount of space is wasted around subplots. For example, in this example: t = 0:0.001:2*pi+0.001; figure(2); for i = 1 : 25; subplot(5,5,i); plot(t, sin(i*t)); axis off end over 50% of the space on the figure…
John
  • 5,735
  • 3
  • 46
  • 62
47
votes
7 answers

How to normalize a histogram in MATLAB?

How to normalize a histogram such that the area under the probability density function is equal to 1?
edgarmtze
  • 24,683
  • 80
  • 235
  • 386
47
votes
10 answers

"Converting" Numpy arrays to Matlab and vice versa

I am looking for a way to pass NumPy arrays to Matlab. I've managed to do this by storing the array into an image using scipy.misc.imsave and then loading it using imread, but this of course causes the matrix to contain values between 0 and 256…
user1444165
46
votes
7 answers

Grayscale to Red-Green-Blue (MATLAB Jet) color scale

I was given a data set that is essentially an image, however each pixel in the image is represented as a value from -1 to 1 inclusive. I am writing an application that needs to take these -1 to 1 grayscale values and map them to the associated RGB…
Adam Shook
  • 709
  • 1
  • 7
  • 10
46
votes
7 answers

How to assign values to a MATLAB matrix on the diagonal?

Suppose I have an NxN matrix A, an index vector V consisting of a subset of the numbers 1:N, and a value K, and I want to do this: for i = V A(i,i) = K end Is there a way to do this in one statement w/ vectorization? e.g. A(something) =…
Jason S
  • 184,598
  • 164
  • 608
  • 970
46
votes
4 answers

MATLAB Compiler vs MATLAB Coder

What's the difference between the two? As far as I understand it, MATLAB Compiler wraps the MATLAB code into a .exe file so that it can be used without installing MATLAB, and only requires the MCR. On top of it MATLAB Builder NE can also be used to…
Win Coder
  • 6,628
  • 11
  • 54
  • 81
45
votes
4 answers

Random order of rows Matlab

Say we have a matrix of size 100x3 How would you shuffle the rows in MATLAB?
edgarmtze
  • 24,683
  • 80
  • 235
  • 386
45
votes
6 answers

Error opening file in H5PY (File signature not found)

I've been using the following bit of code to open some HDF5 files, produced in MATLAB, in python using H5PY: import h5py as h5 data='dataset.mat' f=h5.File(data, 'r') However I'm getting the following error: OSError: Unable to open file (File…
Anisha Singh
  • 483
  • 1
  • 4
  • 6