Articles of matlab

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 modified Bessel functions of the first and second kind, respectively. As $x \to \infty$, we have $K_{0} \to 0$ and $I_{0} \to \infty$, but the integrand goes to […]

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 am not getting that how come this result is possible ? [Editor’s comment #1: The question makes sense, but the asker forgot to explain their notation – possibly because they have not been exposed to any alternatives (happens regrettably often […]

Minimize $\|AXBd -c \|^2$, enforcing $X$ to be a diagonal block matrix

Currently, I am minimizing the quadratic objective $\|\mathbf{A}\mathbf{X}\mathbf{B}\mathbf{d} -\mathbf{c} \|^2$ using CVX, as follows echo on cvx_begin variable xx(num_triangles*3,num_triangles*3) minimize( norm( A * xx * B * d – c ) ) cvx_end echo off However, $\mathbf{X}$ is a very large matrix (about $50,000 \times 50,000$, which is too big). Good news is that $\mathbf{X}$ […]

Robust Control VS Optimal Control

What’s the diffrents between Optimal Control and Robust Control? I know that Optimal Control have the controllers: LQR – State feedback controller LQG – State feedback observer controller LQGI – State feedback observer integrator controller LQGI/LTR – State feedback observer integrator loop transfer recovery controller (for increase robustness) And Robust Control have: $H_{2}$ controller $H_{\infty}$ […]

Monte Carlo double integral over a non-rectangular region (Matlab)

I want to evaluated the following integral using Monte Carlo method: $$\int_{0}^{1}\int_{0}^{y}x^2y\ dxdy $$ What I tried using Matlab: output=0; a=0; b=@(y) y; c=0; d=1; f=@(x,y) x^2*y; N=50000; for i=1:N y=c+(d-c)*rand(); x=a+(b(y)-a)*rand(); output=output+f(x,y); end output=0.5*output/N; % 0.5 because it’s the area of the region of integration fprintf(‘Value : %9.8f\n’,output); However this code didn’t give me […]

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 elements of this sequence inside $J$, i.e. $$ A(J,N)=\left|\{x_1,\ldots,x_N\}\cap{J}\right|, $$ and let $V(J)$ denote the volume of $J$. The discrepenacy of the sequence $x_1,\ldots,x_N$ is defined as $$ D_N=\sup_{J}{\left|A(J,N)-V(J)\cdot{N}\right|}, […]

If $X$ is symmetric, show $k(X^2)$ = $k(X)^2$

Suppose we have a symmetric invertible matrix $X$. How can I find $k(X^2)$ in terms of $k(X)$? Note that $k$ represents the condition number operation, that is $k(X) = \|X\|\,\|X^{-1}\|$. So, after messing around in Matlab for a while, I think $$k(X^2) = k(X)^2$$ although I dont know how to prove it. I think I […]

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 rank(A)~=n A=randi([0 1], n, n); end The above code generates a random binary matrix, with the hope that the corresponding determinant can be […]

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 can get an approximate value for k by guessing m and then doing linear regression on $-\log_2(1-y/m)$… by […]

Solve a second order DEQ using Euler's method in MATLAB

I need to solve the equation below with Euler’s method: $$y”+ \pi ye^{x/3}(2y’ \sin(\pi x)+\pi y\cos (\pi x)) = \frac{y}{9}$$ for the initial conditions $y(0)=1$, $y'(0)=-1/3$ So I know I need to turn the problem into a system of two first order differential equations. Therefore $u_1=y’$ and $u_2=y”$ I can now write the system as: […]