Questions tagged [matlab]

For mathematical questions about MATLAB; questions purely about the language, syntax, or runtime errors would likely be better received on Stack Overflow. MATLAB is a high-level language and interactive programming environment for numerical computation and visualization developed by MathWorks.

Filter by
Sorted by
Tagged with
3
votes
2answers
11k views

Chi square goodness-of-fit test for Uniform distribution using Matlab

I need to test random numbers generators in 1, 2 and 3 dimensions. Criteria of test is that generated numbers are from uniform distribution. I am doing this using Matlab. I'm told to use Chi-2 test ...
3
votes
2answers
3k views

Matlab Code to simulate trajectories of Ito process.

I need some help to generate a Matlab code in order to do the following question. Can somebody help me in this regard. Any sort of hint that could be helpful will surely be appreciated.. Q: "Simulate ...
3
votes
2answers
11k views

Singularity in matrix when inverting in Matlab

As data I get a matrix A but in my algorithm I need to work on its inverse. What I do is: C = inv(A) + B; Then in another line I update A. In the next cycles I ...
3
votes
2answers
4k 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
825 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
6k 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 MATLAB? ...
3
votes
1answer
186 views

complexity cost for which one is greater : determinant or eigen values?

what is complexity cost for determining all of eigen values? what is complexity cost for calculating determinant ?
3
votes
2answers
546 views

shadow simulation from buildings

is it possible to calculate shadow areas of buildings or simulate shadows of buildings in a city, using the heights of these buildings and the sun angle and azimuth? the basic light tracing concept ...
3
votes
2answers
40 views

Problem with the roots of polynomial given by sum of geometric series

Let's say I want to distribute leaflets for 60 months and in total I want to distribute $2500000$ leaflets. In my first month I want to distribute $8000$ leaflets and then I want to increase my speed ...
3
votes
2answers
215 views

Implementation help for Extended Euclidean Algorithm

I'm not sure if this question is entirely on-topic here, please notify if not. I feel it is more a math related problem, than a programming problem. Following the advice in this answer I'm trying to ...
3
votes
1answer
239 views

Discretising a PDE for MATLAB using upwind scheme

I am trying to discretise the PDE: $$\phi \frac{\partial c}{\partial t}+\frac{\partial j}{\partial x}=0$$ where $c$ is a function of $x$ and $t$, and $j=qc-D(q)\frac{\partial c}{\partial x}$, $q$ is ...
3
votes
2answers
550 views

The reverse of finding the arc length

As we know, finding the arc length of a function $f(x)$ from $x=a$ to $x=b$ is straightforward and can be implemented numerically. For a particular function $f(x)$ that I have, suppose that I have ...
3
votes
2answers
115 views

How to solve $\dot{\mathbf{v}} = - \frac{GM}{r^3}\mathbf{r}$ using differential eq-n solver in MATLAB

I need to solve second order system with boundary conditions with help of differential equation solver. The system is $$\dot{\mathbf{v}} = - \frac{GM}{r^3}\mathbf{r}.$$ I tried to use MATLAB ...
3
votes
1answer
832 views

Projection Matrix onto null space of a vector

I have a vector summation $x_1 + Ax_2$ where $x_1\in\mathbb{R}^{n\times1}$, $A\in\mathbb{R}^{n\times m}$ and $x_2\in\mathbb{R}^{m\times1}$. I am wondering if I can find a projection $P\in\mathbb{R}^{...
3
votes
1answer
535 views

in a non-full rank matrix, how to find the dependent rows especifically in MATLAB?

I have a very large matrix, which its determinant is zero, and hence it is not full rank. Now I wonder is there a way to find which rows are linearly dependent? specifically in MatLab is there any ...
3
votes
1answer
1k views

Second order derivative of log of vector

I have a vector of size $n$ x $1$ named $\alpha$. Let $f(\alpha) = u\cdot\mathbf 1^{\!\top}ln(\alpha)$ where $u$ is scalar. What is the $f'(\alpha)$ and $f''(\alpha)$ and equivalent Matlab code? ...
3
votes
1answer
1k 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....
3
votes
1answer
1k views

Surface fitting

I do not need a complete answer but just some advice. I have a sparse matrix of points in a volume. I know a surface passing by these points exists and this surface is mostly flat and relatively ...
3
votes
2answers
199 views

Solve $ A x = b $ with Surrogate Function which Implements Multiplication by $ 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
1k views

How to solve nonlinear constrained optimization in Matlab?

I have to solve a nonlinear constrained function in matlab, and I am not familiar with it's commands. the problem is: minimize $E(b,c)$ constraints: $k1< c\sqrt{b}< k2 ; c/6>k3$ Note: E(b,c) ...
3
votes
1answer
952 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
1answer
483 views

How to proceed solving this problem?

I'm working on the problem "soundwaves under the water" (page 16 in the document is in English) from a numerical analysis book. I've got the following problem that is taken from the numerical ...
3
votes
1answer
2k views

Stratified Monte Carlo

Consider the integral $I=\int_{0}^{1}e^{-x}dx$. Now consider the stratifed Monte Carlo estimate $\hat{I^{s}}$, that has $N_{st}=8$ strata. What is the variance of $\hat{I^{s}}$? What is the percent ...
3
votes
1answer
245 views

non linear optimization

How to solve this optimization problem using matlab or some other tool. I know that, this is a convex problem with non-linear constraint $\rho\geq \rho_{min}$ , so i have tried many times it in ...
3
votes
1answer
1k 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
1k views

Need matlab help related with the iteration method

I am reading an iteration method for computing the Moore- Penrose genralized inverse of a given matrix $A$, which is given as follows: $X_{k+1} = (1+\beta)X_{k} - \beta X_{k} A X_{k}$ where $X_{k}$...
3
votes
1answer
4k 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
48 views

Defining a custom probability density function for Maximum likelihood in matlab

I am trying to minimise a likelihood function and estimate the parameter value of $\lambda$ by fitting to the following data. $t$ is the time and $N(t)$ si the population measured at those specific ...
3
votes
1answer
332 views

Solving an ODE in the complex plane using a MatLab ODE solver

In Matlab, I mostly use the solver ode45 and it seems that I cannot use complex numbers when specifying the interval of integration. An oversimple example would be if I wanted to solve numerically the ...
3
votes
1answer
591 views

Multivariate Polynomial Multiplication using Fast Fourier Transform (FFT)

I am trying to find the coefficients of multiplications of 2 $N$-variate polynomials using $N$-dimensional fast Fourier transform (FFT) on MATLAB. My approach so far is as follows: Based on this post,...
3
votes
1answer
987 views

Matrix multiplication using Galois field

$$\begin{bmatrix}1 &1 &6\\4& 3& 2\\5 &2& 2\\5& 3& 4\\4& 2& 4\end{bmatrix}\begin{bmatrix}4\\5\\6\end{bmatrix} = \begin{bmatrix}3\\5\\4\\3\\2\end{bmatrix}. $$ I ...
3
votes
1answer
660 views

How to calculate discrepancy of a sequence

For $d\geq1$ let $I^d=[0,1)^d$ denote the $d$-dimensional half-open unit cube and consider a finite sequence $x_1,\ldots,x_N\in{I}^d$. For a subset $J\subset{I}$, let $A(J,N)$ denote the number of ...
3
votes
1answer
202 views

How to use boundary condition for Euler-Bernoulli equation

How to use enter boundary condition into a Euler-Bernoulli fourth order equation
3
votes
1answer
4k views

Implementation of EM algorithm for Gaussian Mixture Models using Matlab

Using the EM algorithm, I want to train a Gaussian Mixture model using four components on a given dataset. The set is three dimensional and contains 300 samples. The problem is that after about 6 ...
3
votes
1answer
2k views

Cyclic Redundancy Check of an input sequence using MATLAB

I understand how to mathematically calculate the cyclic redundancy check CRC of bits, for example if the CRC is of length 16 $$ CRC(D) = (M(D) + I (D)) D^{16} \,\,\, mod \,\,\,\ G(D)$$ where $M(D)$ ...
3
votes
1answer
245 views

Fun/Frustration With Coding Coding Theory

it's time for practical coding theory. I am trying to write a simple program that will detected if a given binary code word is "correct" or not. If it is not correct, I want to detect/correct (since ...
3
votes
1answer
763 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? ...
3
votes
1answer
4k views

Low rank approximation using CVX toolbox in Matlab

I try to use CVX toolbox to do "low rank approximation" work. The code is as follows: ...
3
votes
2answers
753 views

LSQR with matlab

I am trying to use LSQR on matlab to solve a linear equations: $$ aX + bY = Z $$ so I form [a b][X Y]' = Z where a, b and ...
3
votes
3answers
5k views

draw an Ellipsoid given its quaderatic equation in Matlab

How can I draw an ellipsoid in Matlab with following equation: $aX^2 + bY^2 + cZ^2 + d XY+e XZ +f YZ +gX +hY+iZ=R^2$ with (for example) $a=1; b=2; c=3; d=4; e=5; f=6; g=7; h=8; i=9; R^2=10.$
3
votes
2answers
387 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
336 views

Partial vs. full eigendecomposition when computing matrix logs with Matlab

I'm looking over a program that performs a matrix logarithm in each iteration, which necessitates looking at the eigendecomposition of the given matrix iterate $M^{(i)}$. However, rather than consider ...
3
votes
1answer
1k 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
911 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
2answers
4k views

How I can get coefficients matrix in MATLAB from the set of linear equations?

I am working in MATLAB and having problem in extraction of coefficients out of my set of symbolic linear equations. Equations are as such ...
3
votes
1answer
430 views

How does Matlab or computer algebra systems find derivatives of functions?

Is it correct that they use a matrix transformation?
3
votes
1answer
2k views

Algorithm for unique “additive” color mixing

my question is if i have only 3 basic colors (each made of rgb): color1 : R:150, B:zero, G:255 color2 : R:255, B:150, G:zero color3 : R:zero, B:255, G:150   They ...
3
votes
2answers
4k views

What is the algorithm for LU factorization in MATLAB?

What is the algorithm for LU factorization in MATLAB, i.e. [L,U] = lu(a)? After searching for many examples and trying to compare the result with MATLAB, they are ...
3
votes
1answer
6k views

Evaluating a line integral of a vector field numerically

I have a vector field (velocity) and I want to integrate around a rectangle. If I had a function for the field it would be easy and I know how to do it. However, I only have the coordinates. Is there ...
3
votes
2answers
3k views

Numerically Solving a Second Order Nonlinear ODE

Okay, I have this not so pretty 2nd order non-linear ODE I should be able to solve numerically. $$f''(R) + \frac{2}{R} f'(R)=\frac{0.7}{R} \left( \frac{1}{\sqrt{f(R)}} - \frac{0.3}{\sqrt{1-f(R)}} \...