MATLAB 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 ... ...

learn more… | top users | synonyms

55
votes
10answers
32k views

What should I learn first, Mathematica or MatLab?

I have a non-professional interest in math and I would like to be able to be curious and play around with some math that I'm learning about (both here and from calculus-and-higher level math classes). ...
18
votes
1answer
6k views

Is Sage on the same level as Mathematica or Matlab for graph theory and graph visualization?

The context: I'm going to start working on a project that involves running predefined algorithms (and defining my own) for very big graphs (thousands of nodes). Visualization would also be welcome if ...
8
votes
3answers
276 views

is there a name for this function (parity of a finite sequence)?

Variants of this question have been crossposted to Stack Overflow and Computational Science Stack Exchange. Additional answers may be found at these other sites. Math people: In an attempt to ...
7
votes
3answers
6k views

Matlab code for generating random symmetric positive definite matrix

Could anybody tell me How to generate random symmetric positive definite matrix using Matlab? Thank you very much for the help and suggestions.
7
votes
0answers
325 views

Problem with an algorithm to $3$-colour the edges of cubic graphs

I'm currently trying to implement an algorithm to $3$-colour the edges of cubic graphs. (I want to do this with Matlab's Symbolic toolbox). After restricting to planar graphs to ensure the existence ...
5
votes
1answer
163 views

What is the difficulty when calculating this integral?

"What is the difficulty when calculating the integral $$\int_0^∞ \frac{6}{x^7+2x+1} dx $$ ? Solve the integral with matlab's quad." Sorry for my bad formatting, I'm just learning this formatting. ...
5
votes
1answer
69 views

Generating $n\times n$ random matrix with rank $n/2$ using matlab

Can we generate $n \times n$ random matrix having any desired rank? I have to generate a $n\times n$ random matrix having rank $n/2$. Thanks for your time and help.
5
votes
4answers
3k views

To “subtract” two matrices with different dimensions in Octave (Matlab)

I have matrix and need to subtract another matrix element by element on each row. Something like this: $$ \begin{pmatrix} x_{1} & x_{2}\\ x_{3} & x_{4}\\ \vdots & \vdots\\ x_{n-1} ...
5
votes
1answer
821 views

Expected Value and Variance of Monte Carlo Estimate of $\int_{0}^{1}e^{-x}dx$

Given the integral: $I=\int_{0}^{1}e^{-x}dx$, use standard Monte Carlo with 1000 random numbers and repeat the simulation 1000 times. (a) What is the expected value and variance of the simple Monte ...
4
votes
2answers
579 views

MATLAB software for graph theory

I'm currently working on an undergraduate thesis that requires the use of graph theory(shortest path problem) in MATLAB. However, all the graph functions that I see in the MATLAB help bar do not make ...
4
votes
2answers
1k views

Solving $Ax=b$ under $L_1$ $|Ax-b|$ minimization

I would like to solve a linear system $Ax = b$ under the $L_1$ norm constraint $\min(|Ax-b|)$. All that I can find about $L_1$ minimization is a way to minimize $|x|_1$ subject to $Ax=b$. I wanted to ...
4
votes
2answers
735 views

Fitting an exponential function to data

I have a noisy data set (the grey line in the graph below) that corresponds roughly to $y=m(1-2^{-x/k})$ where m and k are unknown constants. How can I determine the best-fit value of m and k? I ...
4
votes
1answer
323 views

Matlab numerical triple integral involving quotient of two small quantities

Math people: I am trying to use Matlab's "triplequad" to numerically evaluate the triple integral $$\int_0^1 \int_0^{r_1} \int_{r_1-r_0}^{r_1+r_0} \left[\frac{Ov(r_0,r_1,t)^2}{(\frac{4}{3}\pi ...
4
votes
1answer
128 views

gradient flow programming (matlab)

Consider $$f(x,y)= x \ y \ e^{-x^2-y^2}$$ I need to find the gardient flow of f starting at the point (0,1) then (2,4). I know that this entails solving the follwing ODE $$\dot X(t)= - \nabla ...
4
votes
1answer
344 views

How do I numerically calculate a function from its noisy gradient using “global integration”?

I have the model $\ s(x,y)=x^2+y^2, 0 \leq x \leq 1, 0 \leq y \leq 1 $. Instead of observing the model directly I am observing the derivatives of the model + some noise (e): $\ p(x,y)=s_x+e, ...
4
votes
1answer
496 views

Eigenvalues of unitary matrices

I have a sparse unitary matrix with complex entries and want to compute all its eigenvalues. Unfortunately, matlab doesn't like this. If I try do enter eigs(A, N) (A the matrix, N its size), it tells ...
4
votes
1answer
80 views

Is this a theorem in Statistics? If not, can anyone explain why this seems to be true?

It seems to me that the following is true: If $c$ is a random variable with probability $p(c)$ and cumulative probability $P(c)$, then the probability of $P(c)$ is constant. I have taken $N$ random ...
4
votes
1answer
531 views

How to solve an equation using Newton's method with and without backtracking?

Lets assume I have this equation: $$\log(e^x+e^{-x})=2x+5,\quad x \in (-50,50).$$ As always we have to pick a starting point to solve this by Newton's method, but how can i know for what initial ...
4
votes
2answers
526 views

How to generate and use random trees?

I have the assignment to implement a random tree classifier in MATLAB. The lecture says: ...
4
votes
1answer
1k views

Visualizing elemental rotations using Euler angles in Matlab

I'd like to visualize elemental rotations using Z-Y-X convention in Matlab. If you'd like to follow me exactly, I'll be refering to a paper Quadrotor Dynamics and Control by Randal Beard. The base ...
3
votes
2answers
1k views

Fitting a 3D line to a 3D line point cloud

I want to fit a 3D line to a 3D line point cloud using numerical optimization. Currently, I'm using Steepest Descent and the error function is a function of $\alpha$, $\beta$, $\gamma$; that is, 3 ...
3
votes
3answers
486 views

How to randomly construct a square full-ranked matrix with low determinant?

How to randomly construct a square (1000*1000) full-ranked matrix with low determinant? I have tried the following method, but it failed. In MATLAB, I just use: n=100; A=randi([0 1], n, n); while ...
3
votes
2answers
536 views

Inverse problem from pdes

A linear inverse problem is given by: $\ \mathbf{d}=\mathbf{A}\mathbf{m}+\mathbf{e}$ where d: observed data, A: theory operator, m: unknown model and e: error. To minimize the effect of the noise; ...
3
votes
3answers
68 views

Changing [2,4] into [0,1,0,0,0,1] in Matlab

Good day, I apologize for the very vague title, I didn't really know how to formulate what I want. However, I can explain what I mean: I have a vector v1: ...
3
votes
2answers
193 views

Matlab code for computing index of matrix

I need help to make Matlab code for computing index of matrix. The index of matrix $A$ is the least non negative integer $k$ such that $\operatorname{rank}(A^{k+1}) = \operatorname{rank}(A^k)$. ...
3
votes
3answers
330 views

Factorize Positive Definite Symmetric Matrix

Let's start from the assumption of disposal of a positive definite symmetric matrix of size $\ (N,N) $. For some reason I have to factorize this matrix: I am already aware of the ...
3
votes
2answers
3k views

To invert a Matrix, Condition number should be less than what?

I see that there is a matlab tag in this site, so I ask my question here and not in stackoverflow although it is also related to programming in matlab. I am going to invert a positive definite matrix ...
3
votes
2answers
585 views

Time complexity of quadratic programming

I am using the Matlab built-in quadprog to solve a quadratic program with linear constraints. I vaguely recalled from school that the time complexity of quadratic programming should be $O(n^3)$, and I ...
3
votes
1answer
356 views

Efficient multiplication of super-size matrices in matlab

I don't have enough memory to simply create diagonal matrix D x D, getting an 'out of memory' error. Instead of performing M x D x D operations in the first multiplication, I do M x D operations, but ...
3
votes
1answer
419 views

A problem for Matlab solver

I can numercally solve a system of two ODEs for x and p: dy1 = -y1 + y2 dy2 = -1 + y2 with the following Matlab code: ...
3
votes
1answer
2k views

How to generate orthogonal matrix in Octave?

How to generate an orthogonal matrix in Octave? I saw something like that gallery('orthog',n,k) in matlab, but I can't find ...
3
votes
2answers
180 views

Matrix of matrices in matlab

I need to build up the matrix of matrices. Say, for all $1\leq i,j\leq n$ I have to define a matrix $p_{ij}$ which will be a matrix $n\times n$. What I can do - it is to build up a matrix $P$ which is ...
3
votes
5answers
56 views

Round a set to the nearest values in another set (2D), faster algorithm with Matlab

Given a set of numbers, like A={{1,2.5,3}, {4.2,7,10}}; and another set of numbers, like B={1,2,3,4,5}; Is there a fast ...
3
votes
2answers
993 views

MATLAB code to find distance and eccentricity in graphs

I was trying to find the distances between vertices in graphs. But as the number of vertices are increasing up to 25 vertices or more, its becoming a tedious job for me to calculate $distance$ and ...
3
votes
1answer
417 views

MatLab - Fast Fourier Transform

I have just started messing around with the fft function in MatLab, but can't quite understand the output. Say I write the following: ...
3
votes
2answers
2k views

generating a Gaussian dataset in MATLAB

I want to generate a Gaussian dataset. The dataset includes a total of 800 samples drawn randomly from four two-dimensional Gaussian classes with following distribution: How can I do that in ...
3
votes
3answers
56 views

How can I write an SDE in Matlab?

My professor would like me to solve a system similar to the following: $$ dx_i=[f_i(x_1,x_2,...x_n)]dt + g_ix_idW_i$$ Where $g_i$ are positive constants that measure the amplitude of the random ...
3
votes
1answer
305 views

How to compute elliptic integrals in MATLAB

I need to calculate the complete elliptic integrals of the first and second kind , the incomplete elliptic integral of the first kind, and the incomplete elliptic integral of the second kind in ...
3
votes
1answer
86 views

Matlab: Using calculating with days.

My problem is the following: I have a start day. For example: 30 - Oct - 2010 And I know how many business days I need to count back. For example: 250 business days. Now I want to be able to ...
3
votes
2answers
165 views

Dot product over complex vectors: Conjugate first or second?

Does there exist a truly "standard" dot product over complex vectors? Wikipedia and Wolfram's MathWorld indicate directly or indirectly that the second argument is conjugated. Matlab's ...
3
votes
1answer
598 views

Normalizing scilab's FFT

I want to normalize the FFT used in scilab in a way so that the absolute values of the coefficients equal to the amplitudes of the time domain signal with that frequency. Example: I want an input ...
3
votes
1answer
941 views

MATLAB Hermite interpolation

Anyone know where I can find the Hermite interpolation algorithm in MATLAB. Which Hermite interpolation algorithm solves this? I need to calculate a polynomial. Example: ...
3
votes
1answer
104 views

Solve the differential equation: $y''+(1-2x)y'+2x(e^{x^{2}}-1)y=xe^{x^{2}}$

I have an exercise of solving the equation above using MATLAB, with a hint to set $ v(x)=(y'+y)e^{-x^{2}} $. I tried to do with my hand and get the following: $ v'+2xy=x $, but I don't know what to do ...
3
votes
1answer
47 views

Solve Ax = b, but I have a function that implements A

I have an overdetermined linear system $Ax = b$. I need to choose an $x$. $x$ has about 100 elements in it. If I had the matrix $A$, I would set x equal $A^\dagger b$, the pseudoinverse of $A$ ...
3
votes
2answers
37 views

Generating points from a standard Gaussian

I'm new to Gaussian distributions and I'm trying to generate say, $ N$ points from a $ M$ dimensional standard gaussian. What does this mean? How would I do this in matlab?
3
votes
1answer
276 views

Pair Correlation with Uniformly Distributed Random Numbers

I am trying to reconstruct the following "jiggled" distribution from this article: American Scientist. The article states that the pair correlation function is defined as follows: "For each distance ...
3
votes
1answer
221 views

Switching from Mathematica to MATLAB: As a text editor?

I have been using Mathematica for almost a year, and the most indispensable feature in Mathematica to me has been the ability to write really nice documents and print them into PDF or TEX files. In ...
3
votes
1answer
113 views

Numerical Integration of $\int_0^1 \log(x) dx$

Do you guys have any idea how to handle something like $\int_0^1 log(x) dx$ numerically in Matlab (I'm only interested in the real part btw)? I have used Quad, Quadl, "integral" etc all of them ...
3
votes
2answers
2k views

heat equation with Neumann B.C in matlab

$$ \frac{\partial u}{\partial t}=\alpha\frac{\partial^{2}u}{\partial x^{2}} \qquad u(x,0)=f(x)\qquad u_{x}(0,t)=0\qquad u_{x}(1,t)=2 $$ i'm trying to code the above heat equation with neumann b.c. ...
3
votes
2answers
564 views

Reconstructing space curves from its curvature and torsion

I have to write a program which gets two functions (curvature and torsion) and 3 vectors of the Frenet-Serret "frame" at the starting point - and I have to reconstruct the space curve from this given ...