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
0answers
63 views

Simulation of irrational numbers

I am trying to write an algorithm that generates two random numbers $x_1$ and $x_2$ in a given range such that their ratio $x_1/x_2$ is an irrational number. I understand that all numbers stored on a ...
3
votes
0answers
28 views

How to find eigenvalue trajectories under perturbation

Let $A$ be an $n\times n$ diagonalizable matrix, and given a $n \times n$ perturbation matrix $P$. The perturbed matrix $$ B(t) = A + tP, $$ where $t$ evolves in small steps from 0 to 1. I would ...
3
votes
0answers
56 views

How to deal with the non-uniqueness of SVD in numerical applications?

There are many applications in applied mathematics where the SVD of a matrix comes in handy. For example, consider the problem where we want to find an approximate solution to a(n) (overdetermined) ...
3
votes
0answers
44 views

Deciding the parameter value in a ODE system

I am working with a system that includes pharmacokinetic and pharmacodynamic elements. To model the antibiotic effect on bacteria I am using a commonly used Hill type function as,${(\phi_{max} - \phi ...
3
votes
1answer
180 views

Euler method and bisection method

I'd like to solve the equation $$ \phi''(x) = \lambda \sin (\phi(x)) $$ where $x \in (0,L)$, $\phi'(0) = 0$, $\phi'(L) = 0$. Let $ \psi = \phi'$ and $$ \phi'(x) - \psi(x) = 0$$ $$ \psi'(x) - \lambda ...
3
votes
0answers
74 views

Fun PDEs and exact solutions

I am building an PDE solver and would like some PDEs to test it on. However to test it works I want to compare it to exact solutions but I'm not having much luck finding these online. I currently have ...
3
votes
3answers
87 views

Determine which of $N$ points is not on $\sin(ax + b)$, where $a$ and $b$ are unknown.

Suppose $N$ points ($(x_1,y_1), (x_2,y_2), ... (x_N,y_N)$) are given from a curve $y=\sin(ax+b)$ where $a, b$ values are unknown. Before giving these $N$ points to you, $y$ coordinate of one point is ...
3
votes
0answers
83 views

Identify a state space model from measured inputs and outputs

I'm using subspace identification to identify a black-box state space model. To identify I follow these steps: We have measured a vector of inputs $u_k \in \Re^{m}$ and outputs $y_k \in \Re^{l}$. For ...
3
votes
2answers
4k views

How do I find detectable and stabilizable states in robust control?

Let's say that we have a matrix of transfer functions: $$G(s) = C(sI-A)^{-1}B + D$$ And we create the sensitivity matrix transfer function: $$S(s) = (I+GK)^{-1}$$ Where $K$ is our controller gain ...
3
votes
2answers
461 views

Covariance matrix $P$ for an Extended Kalman Filter not symmetric

I am trying to implement an Extended Kalman Filter (EKF) and it is becoming harder than I thought. I have one question. I noticed that the covariance matrix which should get updated over each ...
3
votes
0answers
275 views

Initial Contour in Level-Set-Method

I am learning Level-Set-Method for the image segmentation. I have a simple question, how people draw the initial contour in the given image, when people need to deform it? Is there a command in ...
3
votes
0answers
156 views

Condition number of preconditioned regularization problem involving Kronecker Product

Situation I have some results from applying right-preconditioned CGLS to the damped normal equations $(A^TA + \alpha^2I)\ \mathbf{x}=A^T\mathbf{b}$. I'm trying to find the condition numbers of the ...
3
votes
0answers
542 views

Unconstrained optimization algorithm

I need to test some Unconstrained optimization algorithms on the Rosenbrock's banana function so that I can compare the performances of those algorithms. Now, I have several resources in my hand, (...
3
votes
0answers
285 views

Euler-Maruyama to solve SDE and show strong and weak convergence

$dX_t = aX_tdt + bX_tdW_t$, $X_0 = x$ is the question and the solution for this is $X_t = xexp{(a-\frac{b^2}{2})t+bW_t}$ a and b are positive constant numbers ...
3
votes
0answers
311 views

Algorithm of LAPACK's banded solver

I was trying to convert a MATLAB program to C program and i came across a problem where i got stuck. My Matlab program has an equation of the form 'A \ B', where '\' is mldivide in MATLAB. Matrix 'A' =...
3
votes
1answer
98 views

How can I write this differential equation system in MATLAB?

I am newbie MATLAB user. How to write this equation system in MATLAB? $$\frac{dN_{ik}}{dt}=\sum_{j=i}^{n}\sum_{l=1}^{n}\beta_{jl}b_{ikjl}S_{jl}N_{jl} - S_{ik}N_{ik}$$ Here, I want to know if I take $...
3
votes
0answers
111 views

How to decompose a 2d shape into sin and cosin modes?

Assume that you have a circle with radius $r_0$, then you keep adding cosine modes as below: $r=r_0+a_1\cos(1\theta)+a_2\cos(2\theta)+a_3\cos(3\theta)+a_4\cos(4\theta)+~...$ if you plot this as ...
3
votes
1answer
903 views

Why Should One Use Backtracking Line Search Method to Implement an Algorithm

I am new to MATLAB and I am asked to implement on matlab the following algorithm: Steepest descent Newtont Quasi-Newton (bfgs) Gauss-Newton using a line search method and the justify my decision. I ...
3
votes
1answer
62 views

Probability of True Positive of a random variable defined by an integral expression

$\newcommand{\Prob}{\operatorname{Prob}}$Let's assume that we have a random variable with the following pdf: \begin{equation} f_T(x) = \int_0^\infty f_T(x,g) \cdot f_{g}(g) \, dg = \int_0^\infty \...
3
votes
0answers
3k views

Please help: My MATLAB code for solving a 2D Schrödinger equation keep giving me weird output. [closed]

I've been trying to solve the following Schrödinger equation numerically, \begin{equation} -(\frac{\partial^2}{\partial y^2} + \frac{\partial^2}{\partial z^2})\Psi + \frac{\sinh^2(y) + \sinh^2(z)}{(\...
3
votes
0answers
211 views

solving PDE with state-dependent boundary conditions

I am interested in solving the following PDE (heat equation): $$\frac{\partial u}{\partial t} = \kappa \frac{\partial ^2 u}{\partial x^2}$$ In order to solve it, I discretize space uniformly into $N$ ...
3
votes
0answers
45 views

A guide on how to approach learning programming [closed]

I am going to take up an introductory course on computational mathematics this semester, in particular, to learn matlab. We are given lecture notes and problem sheets to work through, however I was ...
3
votes
0answers
172 views

Any smart tricks to simplify my nasty integration?

I am trying to solve for the following unpleasant integral $$\int_{\gamma}^{\infty} \bigg[t- \int_{-2}^{2}\frac{ t \ f_X(x)}{1+N \ \big|G(x)\big|^2 \ t^{-3}}\ dx\bigg] \ dt$$ where $N$ is a non-...
3
votes
1answer
1k views

How can we Convert Target Labels for Multiclass Output in a Neural Network?

Please someone give me a clear idea about my stack: For reference, see the previous question made by someone else (https://stackoverflow.com/questions/19593362/ann-multiple-vs-single-outputs) about ...
3
votes
0answers
256 views

Algorithm to find the “optimal” path in a given graph

Assume that $G=(V,E)$ is an undirected connected graph and that $H: V \to \mathbb R$ is a function that assign at each vertex $v \in V$ its height $H(v)$. Think of the pair $(G,H)$ as an energy ...
3
votes
0answers
67 views

what is the significance of Eigen values of autocorrelation matrix?

I am trying to find auto correlation matrix of an image to get Harris corners.Paper I am referring suggest that if eigen values of auto correlation matrix are large the point will be corner point.so ...
3
votes
0answers
199 views

How can I find a tranformation matrix/Mathematical relation between two 5th degree polynomial curves in space?

I have the equation of two 5th degree polynomials which they don`t intersect with each other .Each curve is made of 100 points and these two curves looks similar but there are small differences .I am ...
3
votes
0answers
1k views

The definition and meaning of “machine epsilon” in MATLAB

I am taking a introductory course in numerical mathematics, using MATLAB and a numerical math text that refers to MATLAB often. In the text, the machine precision is defined as: The distance $\...
3
votes
0answers
873 views

Compute eigenvector using given eigenvalue

I have a fairly small matrix (cca 100x100). I have computed first four largest eigenvalues (with modified Lanczsos and Lanczsos with reorthogonalization). I know this might be a rather dumb question, ...
3
votes
0answers
341 views

Is there a way to configure MATLAB's plotchar function to other sizes?

plotchar plots a 35 element vector as a 5x7 grid. Is there a way to plot other grid sizes characteres?
3
votes
0answers
418 views

Iterative solver for the pseudo inverse

I have got the following equation: $\begin{bmatrix} \hat{c}\\ \hat{\lambda} \end{bmatrix}=\begin{bmatrix} B^T \cdot B & H^T\\ H & 0 \end{bmatrix}^+\begin{bmatrix} B^T \cdot Y\\ 0 \end{...
3
votes
0answers
403 views

Interpretation of MATLAB's NaiveBayses 'posterior' function

After we created a Naive Bayes classifier object nb (say, with multivariate multinomial (mvmn) distribution), we can call ...
3
votes
0answers
485 views

Understanding Fourier Transform and FFT

First off, I'm sorry if this is a repost. I am currently writing my thesis, and I've been thrown into some Fourier analysis, which I know nothing of. So, even if this question has been posted before, ...
2
votes
2answers
11k views

I am trying to plot a function and its derivatives with matlab. Getting the error “inner matrix dimensions must agree”

I want to plot x(t)=t*exp(-3*t)+0.25*exp(-3*t), and its first and second time derivatives. I cannot even get the first plot correct. This is what I have done. ...
2
votes
4answers
151 views

$(-1)^{0.2}=0.8090 + 0.5878i$ how can this be?

I'm working on a numerical analysis project (working with matlab a lot) and I noticed that when I ask for matlab to compute the exponent of a negative number, it gives wrong output when the exponent ...
2
votes
1answer
528 views

How to solve Lyapunov equation via Matlab/Octave [closed]

Let's say that I have my Lyapunov equation for finding the controllbility gramian $P$. The equation is: $$APA^T - P + BB^T = 0$$ The matrecies $A, B $ are known. Question: Can I use the command ...
2
votes
2answers
875 views

Classic 10 Balls into 4 boxes problem

Question:Throw at random 10 balls into 4 boxes. What is the probability that exactly 2 boxes remain empty? My Solution: Using the stars and bars method, the boxes and balls can be thought as $0$ and |...
2
votes
5answers
318 views

Nonlinear optimization: Optimizing a matrix to make its square is close to a given matrix.

I'm trying to solve a minimization problem whose purpose is to optimize a matrix whose square is close to another given matrix. But I can't find an effective tool to solve it. Here is my problem: ...
2
votes
2answers
3k views

What does the Matlab loglog plots do that is useful?

If there is a exponential relationship $y = e^x$ and we take the logarithm of this we can see a linear relationship $\ln (y) = x$. So we could plot the logarithm of the y-axis values against the x ...
2
votes
3answers
38 views

Plot graph using maple or matlab

I have tried using maple and matlab to plot this question but it seems to be unable to plot, would to ask if there is any ideas on plotting this question using maple or matlab?
2
votes
2answers
105 views

Rank-Deficiency in an Augmented Matrix comprised of Two Full Rank Matrices

I have a $\boldsymbol{M}_{6\times 6}$ matrix structured as follows: $$\boldsymbol{A} = \begin{bmatrix}a_1 & a_2 & a_3 & 0 & 0 & 0\\0 & a_1 & 0 & a_2 & a_3 & 0\\...
2
votes
2answers
3k views

How to check if two sets of vectors span the same space in matlab/python?

In MATLAB/Python, is there a way to compare the subspaces span by two different sets of vectors and check if they are the same?
2
votes
4answers
638 views

Inverse Chebyshev Recurrence

The Chebyshev polynomials (of the first kind) are a sequence of polynomials defined recursively by $$ \begin{cases} T_{0}(x) = 1 \\ T_{1}(x) = x \\ T_{n}(x) = 2xT_{n-1}(x) - T_{n-2}(x) \end{cases} $$ ...
2
votes
4answers
598 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 ...
2
votes
3answers
2k views

PCA analysis on 1D set of observations

There are lots of discussions on the web about Principal Component Analysis (PCA) and how to use tools such as matlab octave for that. However none of them fit my problem. My problem is that I have ...
2
votes
2answers
5k views

Runge-Kutta algorithm for a given ODE system

consider the system given by: $$x'_{1}=9x_{1}+24x_{2}+5\cos t-\dfrac{1}{3}\sin t$$ $$x'_{2}=-24x_{1}-51x_{2}-9\cos t+\dfrac{1}{3}\sin t$$ with initial values $$x_{1}(0)=\dfrac{4}{3}$$ and $$x_2(0)=\...
2
votes
1answer
38k views

Solving a system with Newton's method in matlab?

I have the following non-linear system to solve with Newton's method in matlab: x²+y²=2.12 y²-x²y=0.04 What is the linear equation system to be solved? Should I ...
2
votes
3answers
5k views

Exact deconvolution of two matrices using numerical techniques

Suppose that I am given two $n \times m$ matrices $\bf{A}$ and $\bf{C}$, and let $\bf{B}$ be a matrix that is convolved with $\bf{A}$, such that: $\bf{A} * B = C$ In the above, $*$ is the ...
2
votes
1answer
404 views

approximating a function by orthogonal projection

I am trying to understand how the coefficients of the 5th degree polynomial has been calculated in https://www.math.wustl.edu/~freiwald/309projapp.pdf for approximating the sin(t) function between [-...
2
votes
4answers
608 views

Singular Value Decomposition of a big rectangular matrix

I have a huge rectangular $m \times n$ matrix (m = 72000, n = 130) and I need to calculate the SVD of this matrix. Obviously the regular SVD will fail. Since it ...