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
10
votes
1 answer

In Matlab how can I exchange the horizontal and vertical axes of an existing plot

Suppose I have vectors x and y, I know I can do plot(x,y) or plot(y,x) to achieve what I want. However, my question is specifically: If I have a plot already created in a figure as plot(x,y), how can I programmatically exchange the horizontal and…
Isopycnal Oscillation
  • 3,234
  • 6
  • 21
  • 37
10
votes
1 answer

MATLAB- passing a function handle parameter into another function as a handle

Working on an assignment involving Genetic Algorithms (loads of headaches, loads of fun). I need to be able to test differing crossover methods and differing mutation methods, to compare their results (part of the paper I have to write for the…
user194638
10
votes
2 answers

How do you unroll a Numpy array of (mxn) dimentions into a single vector

I just want to know if there is a short cut to unrolling numpy arrays into a single vector. For instance (convert the following Matlab code to python): Matlab way: A = zeros(10,10) % A_unroll = A(:) % <- How can I do this in python Thank…
FelipeG
  • 445
  • 2
  • 5
  • 6
10
votes
2 answers

Most efficient way of drawing grouped boxplot matlab

I have 3 vectors: Y=rand(1000,1), X=Y-rand(1000,1) and ACTid=randi(6,1000,1). I'd like to create boxplots by groups of Y and X corresponding to their group value 1:6 (from ACTid). This is rather ad-hoc and looks nasty for…
HCAI
  • 2,213
  • 8
  • 33
  • 65
10
votes
2 answers

matlab in C C++ and C C++ in matlab

It seems that are several ways to call matlab in C C++ and to call C C++ in matlab. While I try to list them here, please point it out If I miss something. To call C C++ in matlab, there are also two methods. The first one is to call functions in C…
Tim
  • 1
  • 141
  • 372
  • 590
10
votes
5 answers

Gram Schmidt with R

Here is a MATLAB code for performing Gram Schmidt in page 1 http://web.mit.edu/18.06/www/Essays/gramschmidtmat.pdf I am trying for hours and hours to perform this with R since I don't have MATLAB Here is my R f=function(x){ m=nrow(x); …
user2201675
  • 125
  • 1
  • 6
10
votes
7 answers

Debugging with breakpoints from console in Python

I'm trying to migrate from Matlab to python. One of the things that is nice about Matlab is that when debugging I can put a breakpoint in some code and do something to call that code form the command line. Using PyCharm + IPython I haven't found a…
user1507844
  • 5,973
  • 10
  • 38
  • 55
10
votes
4 answers

Solving a matrix in MATLAB?

How does one solve the (non-trivial) solution Ax = 0 for x in MATLAB? A = matrix x = matrix trying to solve for I've tried solve('A * x = 0', 'x') but I only get 0 for an answer.
worbel
  • 6,509
  • 13
  • 53
  • 63
10
votes
3 answers

print n*m matrix in matlab

In MATLAB I'm printing a very large matrix this way: fid = fopen('c:\\OUTPUT.txt','wt'); fprintf(fid,'%f\t',T'); fclose(fid); But this is not right! I want to print it like this:(\t between them and \n at the end of row) 1 2 3 4 5 6 7 8 …
bunNyBug
  • 146
  • 1
  • 2
  • 13
10
votes
2 answers

How to sort structure arrays in MATLAB?

I'm working with an image retrieval system using color histogram intersection in MATLAB. This method gives me the following data: a real number which represents the histogram intersection distance, and the image file name. Because they are different…
zenab
10
votes
1 answer

How can I access all field elements of a structure array nested in a cell array in MATLAB?

Here's code that creates an example cell array for this question: mycell = cell([5,1]); for i = 1 : size(mycell) mystruct = struct(); mycell{i} = mystruct; mycell{i}.field1 = i; end I expected mycell{:}.field1 to do what I want, but it…
Chad
  • 1,434
  • 1
  • 15
  • 30
10
votes
7 answers

Matlab index to logic indexing

I have given a list of indices, e.g. i = [3 5] and a vector v = 1:6. I need a function f which returns the logical map for the vector v given the indices i, e.g.: f(i, length(v)) = [0 0 1 0 1 0] Since I will call this function several million…
blubb
  • 9,510
  • 3
  • 40
  • 82
10
votes
2 answers

Matlab Polymorphism

I've got two new-style MATLAB classes - B & C, both concrete subclasses of an abstract parent, A. A is a subclass of hgsetset (handle class). I'd like to put them in an array in MATLAB, and treat them both as As. They are defined, roughly,…
Marc
  • 3,259
  • 4
  • 30
  • 41
10
votes
2 answers

randomly pick number from a matrix in matlab

How can i randomly pick a number from the given following matrix below? A=[0.06 0.47 0.47] I just want to randomly pick a number from the matrix above. I am doing this in matlab enviornment. please help. Also, Is it possible assume a variable…
happyme
  • 233
  • 2
  • 5
  • 16
10
votes
1 answer

How to print an array to a .txt file in Matlab?

I am just beginning to learn Matlab, so this question might be very basic: I have a variable a=[2.3 3.422 -6.121 9 4.55] I want the values to be output to a .txt file like this: 2.3 3.422 -6.121 9 4.55 How can I do this? fid =…
Lazer
  • 90,700
  • 113
  • 281
  • 364