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

4
votes
3answers
1k 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 ...
0
votes
2answers
238 views

Generating a random binary matrix with fixed number of nonzeros

I want an algorithm (just the idea, not the actual code) to generate a random $n$ by $n$ matrix with binary entries, but with the condition that the number of nonzeros must be a fixed number $c$. Any ...
0
votes
1answer
133 views

How to collect coefficients of the same powers?

I am using the Symbolic Math Toolbox, and define polynomials as symbolic objects, e.g.: syms a x y; P = x^2*y + a*x*y^2 + x*y^2; I am looking for a function that ...
2
votes
2answers
142 views

Evaluating differential entropies with Matlab: NaN issue

With Matlab I am trying to evaluate differential entropies. These are integrals like $$\int_\mathbb{R} p(x) \log (p(x)) \mathrm{d}x$$ where $p(x)$ is a probability density function. My $p(x)$ is ...
1
vote
4answers
192 views

Solving a homogeneous system of three ODEs with variable coefficients.

I am interested in solving the following system of ODEs: $$ \begin{pmatrix} x'(t) \\ y'(t) \\z'(t) \end{pmatrix} = a \begin{pmatrix} 0 & -B_2 & B_1 \sin \omega t \\ B_2 & 0& -B_1 ...
1
vote
0answers
109 views

how to conceptually visualize data structures in Matlab

I tend to think of data structures of type Structure.Field.Subfield as analogous to file directories. I.e that Structure is a folder and Field is a folder inside the folder.. etc. Is this a good way ...
1
vote
1answer
1k views

Matlab numerical integration involving Bessel functions returns NaN

I need to numerically compute integrals such as this (some parameters omitted for simplicity): $$ \int_{0}^{\infty} e^{-x^2} I_{0}(x) K_{0}(x) \mathrm{d}x $$ where $I_{0}$ and $K_{0}$ denote the ...
2
votes
1answer
95 views

fft phase plot of pure sine function, why so messy?

I am plotting the phase plot of $sin(2*pi*60*x)$ in the frequency domain. Ideally, we should only see two peaks. How come this is not the case in matlab? ...
1
vote
1answer
3k views

Evaluate derivative of Lagrange polynomials at construction points

Assume, that we have points $x_i$ with $i=1,...,N+1$. We construct the Lagrange basis polynomials as \begin{align} L_j(x) = \prod_{k\not = j} \frac{x-x_k}{x_j-x_k} \end{align} Now according to my ...
0
votes
1answer
101 views

Eigenvectors of singular matrices

I have the following problem (need to state that I am not sure if this is the correct place to ask this question, hope it is): for each velocity I have three set of eigenvalues: $\alpha_{12}$, $\...
1
vote
0answers
63 views

Nonlinear optimization with range constraint

I am trying to solve the following problem, but so far each time trying to program either one or more of the constraints are not satisfied (using Matlab). Phrasing the problem in two different ways, ...
0
votes
0answers
116 views

Matlab. Gaussian mixture model. How to calculate confidence interval?

I have a the parameters of mixture of normal distributions (Gaussian Mixture Model) . How in Matlab to calculate the 95% confidence interval for the mixture of normal distributions? Thank you.
1
vote
1answer
140 views

How does Matlab, Maple, etc…solve algebraic and differential equations internally?

I would be very interested finding out how does Matlab, Maple, etc…solve algebraic and differential equations internally? Anyone know how they do it?
0
votes
0answers
63 views

IIR Filter - Finding Magnitude and Phase

I've been asked to plot the magnitude and phase response of this IIR filter. $H(z)=\frac{0.0534(1+z^{-1})(1-1.0166z^{-1}+z^{-2})}{(1 - 0.683z^{-1})(1-1.4461z^{-1}+0.7957z^{-2})}$ And I've found a ...
0
votes
2answers
2k views

How to solve $Ax=b$ via backward and forward substitution on Matlab

How can I solve $Ax=b$ in Matlab code via LU factorization. I know that the command [L,U]=LU(A) stores the ...
1
vote
1answer
53 views

Row-wise non zero product in matrix notation

If I have a matrix $\mathbf{A}\in R^{m\times n}$, I'd like to express in matrix notation (or at least in a good mathematical notation) the vector $\mathbf{z}\in R^{m}$ whose $i$-th component is the ...
0
votes
1answer
58 views

uniqueness of svd decomposition and its role in statistical analysis

let us consider following model according to following link http://www4.ncsu.edu/~ipsen/REU09/chapter4.pdf it says that : The singular values are unique, but the singular vector matrices are ...
1
vote
0answers
751 views

How to calculate wavelet energy?

Part of my assignment about signal processing says the following: Compute the Discrete Wavelet Transform for the input signals Group the wavelet coefficients in trees growing across scales ...
0
votes
1answer
51 views

why do I get the following result with Matlab's SVD?

I am doing an SVD on a random matrix in Matlab $A = U S V'$. Then, I do calculate $B = U V'$. Finally, I do SVD on $B = U_2 S_2 V_2'$. I would expect $U_2 = U$ and $V_2 = V$ up to a permutation and ...
0
votes
1answer
430 views

Implementing 1D Discrete Wavelet Transform in Matlab

I'm trying to write my own version of the Discrete Wavelet Transform using the bior4.4 filters. I think my implementation is not properly working yet, because whenever I input a signal and a number ...
-2
votes
1answer
183 views

plot multiple discrete graphs on the same figure

having troubles using 3 stem function on the same figure. my code (only for the plot part) is: ...
0
votes
0answers
295 views

DFT of vector $(0, 1, 2, 3)$

The problem is that my answer is different from answer i get in MATLAB. My answer is $(6, -2-2i, -2, -2+2i)$ while MATLAB answer is $(6, -2+2i, -2, -2-2i).$ In MATLAB i use command ...
2
votes
0answers
257 views

Math notation for expressions using logical (binary) masks on images (matrix)

I need to write up what I have written in matlab: I have an image (that is, a matrix) $K$ and some other matrix of the same size $M$ which acts as a mask which represents the values I would like to ...
2
votes
1answer
81 views

improving symbolic generation of objective function for optimization

I am currently using matlab to solve an optimization problem. I am generating the objective function using the symbolic toolbox. I planned use the symbolic toolbox to calculate the gradient and ...
2
votes
1answer
182 views

Creating an ellipsoidal 3D surface

I am trying to find the equation of a 3D ellipsoidal surface. I have thought of two approaches which are schematically shown below: By revolving an elliptical arc over a 3D elliptical path: Or by ...
1
vote
1answer
2k views

MATLAB curve fitting - least squares method - wrong “fit” using high degrees

Anyone here that could help me with the following problem? The following code calculates the best polynomial fit to a given data-set, that is; a polynomial of a specified degree. Unfortunately, ...
1
vote
1answer
32 views

Compute $\left(a_{i}A+B\right)^{-1},\qquad i=1,\ldots,N$ efficiently?

I need to compute the inverse matrix: $$(a_i A+B)^{-1}, \qquad i=1,\ldots,N$$ where $N$ is a large number. $A$ and $B$ are general $M\times M$ matrices independent of $i$. The only thing that ...
0
votes
1answer
194 views

How to define a meshgrid (x,y) between the intersection of two oblique lines.

How can I create a meshgrid to draw a 3d surface in a domain (zone 1) defined by the intersection of two oblique lines in Matlab (see attached figure)1. The variables 0
2
votes
0answers
98 views

how to use Matlab ifft to calculate the following integral? [duplicate]

$$R(t)=\int_{-\infty}^\infty\dfrac{\omega e^{i\omega t}}{(3-\omega^2)^{2}+4\omega^2}\,d\omega$$ where t is a integer and $t>0$ I used to calculate this integral by numerical integral,but it seems ...
0
votes
2answers
515 views

How to use Monte Carlo method to find volume?

So the question asks to use the Monte Carlo method to find the volume of an irregular figure defined as: ...
0
votes
1answer
63 views

Matrix Factorization of lower triangular and unit upper triangular.

So I have a matrix. $$A =\begin{bmatrix} 8 && -3 && 2 && -1\\ -3 && 8 && 0 && 2\\ 2 && 0 && 8 && -3\\ -...
2
votes
1answer
352 views

Gauss quadrature on tetrahedron

I have the Weights ${\bf w}=[w_1\,w_2\, w_3\, w_4]=[0.25, 0.25, 0.25, 0.25]/6$ and the points ${\bf x_1}=[0.1381966011250105 , 0.1381966011250105 , 0.1381966011250105]$ ${\bf x_2}=[0....
0
votes
0answers
33 views

Guassian quadrature

Consider the polynomial $L \in P_5$ defined by $$L(x)=\frac{d}{dx^3}(1-x^2)^4$$ My question is to use a technique similar to the one used in the analysis of the Gaussian quadrature to show that Q has ...
1
vote
1answer
35 views

Replaces data in a matrix with Matlab

A is a matrix (6 ×6) defined as: A= [0.25 0.35 0.46 0.56 0.67 0.78; 0.25 0.37 0.49 0.61 0.73 0.86; 0.25 0.38 0.52 0.66 1.80 1.94; 0.25 0.40 ...
0
votes
1answer
73 views

MINLP optimization with matlab reaching different solutions every run

I have written a program for optimizing a set of generators. I have hourly price and cost data and need to figure out when a generator should run or just stay off. I describe the problem in more ...
0
votes
1answer
171 views

matlab MINLP optimization with ga

I have written a program for optimizing a set of generators. I have hourly price and cost data and need to figure out when a generator should run or just stay off. There are additional constraints but ...
0
votes
1answer
223 views

integer linear programing in matlab with the symbolic toolbox

I am writing a program to optimize a set of generators. I have hourly data and but dont want to necessarily optimize the whole time series. For a similar problem in the past I used the symbolic ...
1
vote
1answer
906 views

Matlab simulation of dog chasing a rabbit pursuit curve.

Hi I'm really struggling with this problem of mine. A rabbit is running along the x-axis (0->∞) with a constant velocity vr and a dog chases the rabbit starting at some point L (0...∞) on the y-axis ...
1
vote
0answers
86 views

Matlab Newton's Method Non-linear system

There is something wrong with this program and I cannot seem to find it. I am trying to calculate the solution of a non-linear system using Newton's method. Matlab keeps saying there is a problem with ...
2
votes
3answers
53 views

MATLAB: matrix multiplication with exponentiation

Normal matrix multiplication computes $C=A*B$, such that $C_{ij}=\sum_k{A_{ik}*B_{kj}}$ I want to compute D, such that $D_{ij}=\sum_k{e^{A_{ik}*B_{kj}}}$ Basically I want to exponentiate each ...
0
votes
2answers
9 views

Generating points from bi variate normal mixture densities

I am asked to generate 200 and 1000 points from a bi-variate normal mixture densities. I am trying to understand the algorithm, not just the matlab code (I have to write it, not use an existing ...
1
vote
1answer
370 views

plotting cone on matlab

Plot the portion of the cone $z=sqrt((x − 1)^2 + y^2)$ inside the cylinder $r = 2$ This is my matlab code. However, I get an error with the ezsurf line. Any ideas as to what I might be doing wrong? ...
0
votes
3answers
1k views

determine unit outward normal vector on a curve

It is necessary for me to find unit outward normal vector for the curve: $$\gamma=(x(t),y(t))$$ where $$x(t)=(0.6)\cos(t)-(0.3)\cos(3t)$$ and $$y(t)=(0.7)\sin(t)+(0.07)\sin(7t)+(0.1)\sin(3t)$$ I ...
0
votes
1answer
190 views

Incomplete Cholesky decomposition conjugate gradient method in Matlab

I have a problem in finding the numerical material that describing in detail for incomplete Cholesky combined with conjugate gradient method by using Matlab. Someone can help me? Many thank in advance....
1
vote
1answer
67 views

Matlab solution for non-homogenous heat equation using finite differences

Given the following PDE (non-homogenous heat equation): $$ u_t(x,t) = c^2u_{xx}(x,t) + f(x,t) $$ $$ u(0,t) = u(l,t) = 0 $$ $$ u(x,0) = g(x) $$ $$ 0 < x < l ; t > 0 ; c > 0 $$ I wrote the ...
0
votes
1answer
76 views

Matlab Recursion Loop

I need to create a loop to answer part c of the following linear algebra question. I'm new to Matlab so this is extremely confusing. I'm not sure how to make a loop that "counts" from 0-25 in order to ...
1
vote
1answer
66 views

Least Squares in Matlab

I'm stuck on part (d) I'm not sure how to code it so that it approximates that function in matlab. I'm also not sure if my (a) thru (c) are correct. But this is what I have so far. ...
0
votes
2answers
42 views

Matlab code for creating matrix

I have a problem, I am working with numerical approximations. Now i have $-1=x_0<x_1 <...<x_n=1$ with $x_i=x_{i-1}+h$ and $h=2/n$. Now given a function $f$ , I want to find $f(x_i)$ for $i=1:...
0
votes
1answer
300 views

creating a tridiagonal matrix in scilab/matlab

I want to create a tridiagonal matrix in scilab/matlab such that it uses for loops. I dont know how to create the matrix but here is what i have started ...
2
votes
0answers
194 views

Phase retrieval via SDP (semidefinite program) of 2D test image (Matrix completion)

In SDP based phase retrieval we have intensity measurement (abs(FFT2(x))^2) of the form A(xo) = |ak,x|^2 =b^2, phase retrieval is then find x that obeys A(xo)=b The quadratic measurements can be ...