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

26
votes
1answer
10k 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 ...
22
votes
3answers
2k views

Matlab wrong cube root

How can I get MATLAB to calculate $(-1)^{1/3}$ as $-1$? Why is it giving me $0.5000 + 0.8660i$ as solution? I have same problem with $({-1\over0.1690})^{1/3}$ which should be negative.
11
votes
4answers
15k 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.
10
votes
3answers
199 views

What function could describe this GIF animation?

I found this image on Beautiful Mathematical GIFs Will Mesmerize You and this GIF really caught my attention. From what I see, it's a 2D circle morphing into the 3D sphere. What function could ...
8
votes
3answers
455 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
2answers
2k views

Fast Matlab Code for hypergeometric function $_2F_1$

I am looking for a good numerical algorithm to evaluate the hypergeometric function $_2F_1$ in Matlab (hypergeom in Matlab is very slow). I looked across the ...
7
votes
4answers
4k 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} ...
7
votes
1answer
3k 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 ...
7
votes
1answer
433 views

Fast algorithm for approximating Eigenvalue distribution of large sparse matrix

I am interested in the eigenvalue distribution of a huge $2^{16}$x$2^{16}$ Hermitian sparse matrix with spectrum contained in $[-1,1]$. That is I don't need to know all eigenvalues exactly, but rather ...
7
votes
0answers
377 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 ...
6
votes
2answers
378 views

Image Reconstruction:Phase vs. Magnitude

Figure 1.(c) shows the Test image reconstructed from MAGNITUDE spectrum only. We can say that the intensity values of LOW frequency pixels are comparatively more than HIGH frequency pixels. $$ ...
6
votes
0answers
84 views

fixed point iteration

I am trying to find the root of $f(x)=\arctan(x)$ by using successive iteration. There are some conditions to apply this in successive iteration . 1) The function has to be continuous. 2) ...
6
votes
0answers
77 views

How to solve this equation (may be with least squares)?

I have a system of linear equations in the following form. How can I solve it? $$\operatorname*{argmin}_{a,b} \sum_{i,j} \left( \left| X(i,j)-aY(i,j)\right|-b \right)^2$$ Where $X$ and $Y$ are ...
5
votes
1answer
105 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
1answer
179 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
179 views

How to use Newton's method to find the roots of an oscillating polynomial?

Use Newton’s method to find the roots of $32x^6 − 48x^4 + 18x^2 − 1 = 0$ accurate to within $10^{-5}$. Newton's method requires the derivative of this function, which is easy to find. Problem is, ...
5
votes
2answers
3k 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 ...
4
votes
4answers
170 views

Why can you not omit the '*' sign for multiplication in Sage, Matlab, and other mathematical software?

Question I have some experience with Sage and Matlab. Both mathematical software packages require you to have the '*' sign when multiplying symbolic variables with integers. For example, in Matlab ...
4
votes
3answers
1k 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 ...
4
votes
2answers
1k 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; ...
4
votes
3answers
516 views

How to calculate $\exp(-x)$ using Taylor series

We know that the Taylor series expansion of $e^x$ is \begin{equation} e^x = \sum\limits_{i=1}^{\infty}\frac{x^{i-1}}{(i-1)!}. \end{equation} If I have to use this formula to evaluate $e^{-20}$, how ...
4
votes
2answers
7k 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 ...
4
votes
2answers
2k 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 ...
4
votes
1answer
4k 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 ...
4
votes
1answer
49 views

Principal component analysis (PCA) results in sinusoids, what is the underlying cause?

Background I'm analysing a data set of $M$ flow measurements (volume per time). The flows go from zero mL/s gradually to higher values and back to zero again, thus: their shapes ideally look like a ...
4
votes
2answers
276 views

Implementing Ornstein–Uhlenbeck in Matlab

I am reading this article on Wikipedia, where three sample paths of different OU-processes are plotted. I would like to do the same to learn how this works, but I face troubles implementing it in ...
4
votes
2answers
2k 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
3k 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
1k 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
34 views

How can I compute $\sum_{i=1}^n x_i \log(x_i)$ in a stable manner?

Given a vector in $\mathbb{R}^n$ I have an algorithm to compute $$\sum_{i=1}^n x_i \log(x_i)$$ However for my application the norm of $x$ must be 1, hence for big $n$ the components tend to be too ...
4
votes
3answers
113 views

Newton's Method: Found a case where it doesn't work. Why?

So I was looking to use Newton's Method to evaluate $x^3-2*x+2 = 0$. I noticed that I could plug in a negative number for $x_0$ and it worked but when I tried $x_0 = 0$ then my code started going ...
4
votes
1answer
323 views

Due to numerical inaccuracy, the solution of a boundary value problems becomes negative

I treat a toy example to get my point across. In reality I have to deal with a much more complex model. Let us consider a one dimensional boundary value problem using the bvp5c solver in Matlab. Two ...
4
votes
1answer
456 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
2k 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 ...
4
votes
1answer
385 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
159 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 ...
4
votes
1answer
657 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
692 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
53 views

Did I do something wrong solving this PDE in MATLAB?

I have the following PDE problem on a practice exam: I have completed the problem using MATLAB to the best of my ability. Here is the code I used ...
4
votes
1answer
43 views

How can I set values going up by powers of $2$ in matlab [closed]

I am writing a code which will need values of $\sin(x)$ for $x = 2^2, 2^3, 2^4, \dots, 2^{25}$ Being fairly new at matlab still, I am unsure how to do this in the most efficient manner. I know ...
4
votes
1answer
92 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
2answers
5k 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. ...
4
votes
1answer
690 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
853 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 ...
4
votes
2answers
592 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
0answers
119 views

Matlab's dwt2 in publication quality notation?

I used Matlab's dwt2in my algorithm, what notation have you folks seen that describes the 4 resulting wavelets? How do I express ...
3
votes
7answers
464 views

Best Math Plotting Software for Electrical Engineering

I am an electrical engineering undergrad. I would like to learn a math plotting software which would be helpful in visualizing topics in advanced calculus (my immediate need). It would also be helpful ...
3
votes
2answers
3k 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
16k views

Matlab Speech Recognition - Mel-Frequency Cepstrum Coefficient (MFCC)

I'm following this Matlab Speech recognition tutorial. I'm stuck on page 5 on the term/concept of MFCC feature vectors. I'm unable to grasp the concept of what an MFCC is.. a matlab function, ...
3
votes
2answers
96 views

In a linear program, how to add a conditional bound to x?

I am working with a standard linear program: $$\text{min}\:\:f'x$$ $$s.t.\:\:Ax = b$$ $$x ≥ 0$$ Goal: I want to enforce all nonzero solutions $x_i\in$ x to be greater than or equal to a certain ...