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.

0
votes
1answer
27 views

fractional imaginary calculation

Assume $j=\sqrt{-1}$, to calculate $(-3.1416j)^{0.5}$ in Matlab, I type (j*-3.1416)^0.5 and it gives me the result: ...
1
vote
1answer
139 views

Crank-Nicolson code for in-situ combustion model (MATLAB)

I need to solve in MATLAB the following system (1): \begin{align} &\frac{\partial \theta}{\partial t} + u \frac{\partial (\rho\theta)}{\partial x} = \frac{1}{\text{Pe}_T} \frac{\partial^2 \...
0
votes
0answers
26 views

How to simplify exponential matrix complex output in MATLAB?

I want to use MATLAB to find $e^{\mathbf{A}t}$ for $$\mathbf{X'}=\begin{pmatrix} -3 & -1 \\ \phantom{-}2 & -1 \end{pmatrix}\mathbf{X}$$ this is what I wrote in the command window ...
0
votes
1answer
26 views

Plotting basis vectors of a 3D local coordinate system defined by a homogenous transform

Given a 4x4 homogenous transform $H$ I know that the first three columns of $H$ (ignoring the last row) define the basis vectors of the 3D coordinate system that it moves its "parent" coordinate ...
1
vote
0answers
19 views

Estimating probability density function of big amount of data coming from Monte Carlo simulation

I am trying to estimate Probability Density Function (PDF) of a big amount of data ($1e^6$ , $1e^7$, and higher) coming from Mote Carlo (MC) simulation. My objective is to estimate the PDF (e.g. with ...
0
votes
0answers
37 views

Plots in MATLAB

Is it possible to generate by MATLAB, plots and subplots like the ones below? The plots come from an economics paper (http://people.bu.edu/sgilchri/research/GSSZ_FHMU.pdf) and I have looked at ...
0
votes
1answer
63 views
0
votes
0answers
20 views

Fredholm determinant

Suppose we have a Jacobi unitary ensemble $W$ with eigenvalues $-1<\lambda_{1}\leq \lambda_{2}\leq \cdots\leq \lambda_{n}<1$. We can express the eigenvalue correlations near $1$ in terms of the ...
0
votes
2answers
32 views

How to find a non-singular sub-matrix in a full-rank matrix.

Suppose we are given $A\in\mathbb{R}^{n\times m}$, where $n<m$, and we know that $A$ is a full-rank matrix. What is a simple and efficient way to find any submatrix $B\in\mathbb{R}^{n\times n}$ ...
0
votes
0answers
40 views

Want to compute product of Bessel and Hankel function in Matlab - $J_m(x)\cdot H_m^{(1)}(y)$ - but large order or argument returns 'inf'?

I am trying to compute (in Matlab) the product of a Bessel function and a Hankel function where the order $m$ of the functions may be very large and/or the arguments $\alpha x$ and $\alpha y$ of the ...
0
votes
0answers
8 views

BVP with intermediate constraints (Multipoint BVP?)

I have a scalar BVP in the form $$\ddot{n}(t) = f(n(t),\dot{n}(t),t)$$ with BCs $\dot{n}(0) = \dot{n}(t_f)=0$. In addition to these BCs, I have constraints on velocities as $\dot{n}=0$ at ...
1
vote
0answers
18 views

Is there mistake in derivation/simulation of Maximum A Posterori (MAP) estimation?

I'm trying to estimate $X$ using MAP Estimator. If $Y = aX + N$, where $a$ is a constant, $X \sim \mathcal{N}(0,\sigma_{x}^{2})$ and $N \sim \mathcal{N}(0,\sigma_{n}^{2})$. The likelihood function ...
0
votes
0answers
7 views

2D Meshing of an Arbitrary Polygon in Matlab

I am trying to create meshing for an arbitrary polygon; such as, ...
0
votes
0answers
11 views

Finite range Caputo's fractional derivative in Matlab

I need to find a Matlab code that computes the finite range Caputo's fractional derivative, that is, in the definition, change the integration interval $(a, x)$ for $(x- \epsilon,x)$, where $\epsilon \...
1
vote
1answer
695 views

Euler-Maruyama simulation of an SDE

The Euler-Maruyama method for the following SDE \begin{align} dX_{t} &= -\lambda X_{t}dt + \mu dW_{t}\\ X_{0}&=x>0 \end{align} where $\lambda,\mu$ are given constants, is (according to ...
0
votes
0answers
15 views

Matlab and Cauchy's Argument Principle: Plot the contour on the s-plane of a transfer Function

Questions 1. How do I plot the contour of a given Nyquist plot onto the *s-plane of a given transfer function on Matlab? *s-plane: is the complex plane on which Laplace transforms are graphed. It ...
0
votes
0answers
35 views

Phase Diagram for a System of Ordinary Differential Equations

In an economics paper, there is this system of first-order ordinary differential equations: The author then plots its phase diagram for $i(t) = 0$ for $t \leq T$ and reaching $(0,0)$ at $t = T$: My ...
0
votes
1answer
869 views

Projectile with air drag using MATLAB

Unsure where to ask this question because it involves coding and mathematics. I am currently using the code ...
3
votes
1answer
37 views

Composite 2D Simpsons Rule with odd intervals

This question is an extension of this question for 2D integration. The formulation of the problem is based on this page Basically, the composite Simpson's rule for 2D integration is $ \iint_R f(x,...
0
votes
1answer
45 views

Making a animation in Matlab, timedependent function $T\mapsto R_T$

I am dealing with the Pontryagin-Maximum-Principle and i calculated the so called reachable set $R_T$. I am using the following code that plots the reachable set for a certian endtime $T$: ...
0
votes
2answers
62 views

General 2nd order ODE with non-constant coefficient

I'm trying to solve the general case of second order ODE: $y''(t) + p(t)y'(t) + q(t)y(t) = 0$. where $p(t)$ and $q(t)$ are polynomials divides contains some symbolic constant and $t$,$t^2$,$t^3$ and $...
0
votes
2answers
51 views

Help with integration of first moment from PBE

I'm wondering anyone can help me with the following integration: $$\frac{d(m_0 V)}{dt} = BV$$ where $B$ is just a constant, $V$ is a variable parameter. Product rule must be applied somehow? EDIT: ...
1
vote
1answer
992 views
2
votes
0answers
30 views

How to calculate reletive weights (alpha) in Principal Component Analysis

I am trying to work through the method described in this paper of calculating a normalcy index using principal component analysis. I understand steps 1-5, except for the equation for eigenvectors ...
0
votes
2answers
26 views

Change boundary conditions for an ODE system

I'm trying to solve numerically a problem like the next one: \begin{cases} y'(t) = x(t)+y(t) \\ x'(t) = x(t)-y(t) \\ x(0) = x_0 \\ y(T) = y_T \end{cases} with $t\in[0,T]$ I want to ...
-2
votes
0answers
22 views

Matlab code for Neumann Boundary Condition

Use the central difference method with $(1)$ the first approach (one-sided expression) and, $(2)$ the second approach (second order accuracy) to solve: $$u''=\exp(x),\space0<x<1$$ $$u'(0)=0, \...
0
votes
2answers
38 views

Solving a large and complex nonlinear system of equations [closed]

How can I solve the following system of nonlinear equations? $$\begin{split}f_{k}=&\\ &a_1^2(p_{k}s_1+q_{k}s_2+r_{k}s_3)(2x_i+p_{k}s_1+q_{k}s_2+r_{k}s_3)+\\ &a_2^2(p_{k}s_4+q_{k}s_5+r_{k}...
0
votes
1answer
37 views

How do I solve for the velocities in the matrices?

I derived four equations and put them into their matrix form. How can I solve for velocity with them? $$ \begin{split} m_s \ddot{x}_s + R_{s1}\dot{x}_s + R_{2s}\left( \dot{x}_s - \dot{x}_m\right) ...
-1
votes
1answer
44 views

Using matrices, what is the general form for solving a series of coupled differential equations?

I have derived two equations describing the forced vibration of a coupled harmonic oscillator system. Coupled Equations A colleague of mine suggested using: $Ax = B$. However, I don't know how to ...
0
votes
2answers
44 views

How to solve $Mx=b$ where singular M but setting $x_n=0$ for some $x$ allows unique solution

I want to solve $Mx=b$ where $M$ (concrete example below) is singular, but where I can arbitrarily set some $x_i=0$ .. in which case I believe there should be a unique solution for $x$? But how how do ...
2
votes
1answer
63 views

2D quasilinear system of conservation laws - MATLAB

I need to learn how to construct a simple program in MATLAB to solve a 2D quasilinear system of conservation laws with initial values (Cauchy problem) constant by partes (Riemann problem). I am with ...
0
votes
1answer
2k views

Lagrange Interpolation Polynomial Code for coefficients

Can someone help me with developing a simple MATLAB code that inputs the n datasets $ \lbrace x_i : i=0,...,n \rbrace$ and $ \lbrace f^i : i=0,...,n \rbrace$ and produces the coefficients $ \lbrace ...
0
votes
0answers
12 views

Using Frenet coordinates as a metric

Having two trajectories, one that is my target and one which is the result of a system trying to follow the target trajectory, I get two slightly different trajectories as a result. The first is my ...
0
votes
0answers
36 views

normalizing by using gaussian distribution for negative and positive numbers and feed in Min,Max normalization

I'm dealing in Python with a dataset which has 6 million float numbers belongs to 3 main parameters A, B , C and I map them in 24x20 matrices for each cycle and I plot them 480-values by 480-values. ...
3
votes
1answer
889 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
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 ...
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 ...
0
votes
0answers
51 views

Second order difference plot

I am working on a project in which I need to compute the second order difference plot (SODP) of a data series. The data vector is x(n) and I need to compute following values to plot on a graph: ...
0
votes
0answers
14 views

3D plot of a residue image in MATLAB

I'm pretty new to MATLAB and am working on image denoting functions and algorithms. I'd like to see the effect of 2 parameters $h$ and $\gamma$ on a residue image which I have with me. I want to ...
0
votes
1answer
972 views

Solving Markov chain in MATLAB

I am sitting in a class for Markov chains/processes, having no real background in probability but high school knowledge. Now I gotta go through it and I found it better understandable than I had ...
2
votes
2answers
2k views

How do I build this band matrix in MATLAB?

I need to build a pentadiagonal matrix in MATLAB like this: $\begin{pmatrix} 1+2\lambda & -\lambda_1 & 0 & -\lambda_1 & 0 & \cdots & 0\\ -\lambda_1 & 1+4\lambda_1 & -\...
0
votes
2answers
444 views

A question concerning Toeplitz matrices

I am studying Toeplitz matrices. I have to find out the eigenvalues of the following Toeplitz matrix: $$\begin{bmatrix} 2 & -8 & -24 \\ 3 & 2 & -8 \\ 1 & 3 & 2 \end{...
0
votes
1answer
27 views

Find the points of the trajectory in which the velocity is 9

I have a parametric curve given by $M:[0,2]\rightarrow\mathbb{R}; x(t) = 3t^2, y(t) = t^3,z(t)=6t$. I need to find the points of its trajectory in which the velocity is 9. I also need to represent ...
1
vote
0answers
31 views

How to calculate real pixel color from a blurred image using $n$ equations in $n$ unknowns?

I've been dealing with a big image de-blurrying issue for past months and now I'm stuck with this issue that I want to get original sharp image from a blurred image by using some extra data and math. ...
0
votes
3answers
70 views

Plotting first and second order ODE

Here is the second order differential equation: $\frac{d^2x}{dt^2} + \sin(x) = 0$ with initial conditions $x(0)=1$ and $x'(0)=0$. The written code in matlab that numerically solves and plots the ...
0
votes
0answers
28 views

Turing Pattern MATLAB code

I am very new in learning turing patterns. Can someone guide me with a sample MATLAB code to generate following type of figures: I have seen in papers that they mention those figures as 'snapshots of ...
0
votes
1answer
63 views

Numerical Methods with MATLAB - A linear hyperbolic system

I am studying Numerical Methods for Conservations Laws with MATLAB by first time and I've tried to follow an example and calculate the solutions for the following Riemman Problem: $$\begin{bmatrix}u\\...
1
vote
1answer
37 views

3D plot difference Matlab and Wolfram

I'm trying to plot the function $z = 6x^2 - 4x^2y^2$ in Matlab. The code I'm using for this in matlab is the one below, also the plot is shown: ...
1
vote
1answer
2k 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 ...
2
votes
1answer
41 views

FFT from scilab is different than wolfram alpha [closed]

I am getting completely different values of FFT([1,2]) in scilab and Wolfram. I wondering what is going on and who is right. ...