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
0
votes
0answers
14 views

Simplify non-linear system in MATLAB/Octave before solving

Background In my problem, as $V$ increases from $0$ to transitional value $V_T$, $J$ is better described by a function of $\alpha$, $\phi$ and $F=V/L$: \begin{equation}\tag{1} J=k_1F^{2\alpha}\exp(\...
-1
votes
0answers
8 views

Formula for variance of “Discrete” Normal Distribution

Is there a formula based approach to estimate the expected StDev./Variance of a Discrete Normal dataset? Say if mean =0 and StDev. =1, then what would be the expected StDev. of resulting dataset (say, ...
0
votes
1answer
49 views

image of a two variable function in Matlab

Could anyone tell me how to plot the image of the following function in a two-dimensional plane in Matlab (R2018b) by possibly a Matlab code or command? I mean I want to see a curve in $\mathbb R^2$ ...
0
votes
1answer
60 views

Eigenvalues give $(\lambda I - A)$ rref to identity

This is my first post. I'm sorry I don't have mathjax. I'm working through some linear algebra problems, and I keep running into situations where $[(\lambda I-A)]$ (where $A$ is a matrix, $\lambda$ is ...
-1
votes
0answers
26 views

LaPlace transform in Matlab

My transfer function in z domain is: $$ \frac{B(z)}{A(z)} = \frac{(-0.0001988z^{-1} + 0.0005962z^{-2} - 0.0005963*z^{-3} + 0.0001989z^{-4})}{(1 - 1.11z^{-1} - 0.03133z^{-2} + 0.1665z^{-3})} $$ Ts = 0....
1
vote
0answers
17 views

how the plot done for invariant measure?

$X_{n+1}=f_{\omega_n}(X_n), \omega_n$ are iid discrete random variables taking values in $\{1,2,3,4\}$.There are four functions on $[0,1]$, $f_1(x)= \frac{x}{3}$ with probability $p/3$, $f_2(x)= 2/3-...
-1
votes
1answer
40 views

Matlab code for iterated function system [closed]

$f_1(x)=1.2x(1-x), f_2(x)=2.8x(1-x)$ on $\mathbb R$, Now from a starting point $x_0=0.25$,an the iterated function system $x_{n+1}=f_{\omega_n}(x_n), n=0,1,2,\dots$ where $\omega_n$ are i.i.d ...
1
vote
1answer
43 views

LQR with augumented state design

I am trying to design a LQR controller with Integral action (Linear-Quadratic-Integral control) for a below plant. The plant has 4 states, 2 inputs and 4 output. Is it possible to track 4 reference ...
0
votes
0answers
10 views

export mesh and map it to another one in PDEtool

I'm working on PDEtool in Matlab to find eigenvalues for a specific PDE. My question is how can I export the mesh after solving the PDE using the code and how can I use this mesh to map it to another ...
0
votes
0answers
15 views

Dynamic Programming with two endogenous states

I have a dynamic programming problem. I have two endogenous and one exogenous state variables and I need to code this in Matlab. All states are continuous (time is discrete). I can easily code a ...
0
votes
2answers
44 views

How do I plot the following graph in Matlab code?

How do I plot the following graph in Matlab code with same dot lines and continuous line as in the graph? What is the code? The slant line is the $\eta=2 \xi+1$. I am a beginner in matlab. Kindly ...
0
votes
1answer
63 views

Spherical coordinates w.r.t. nonstandard basis vectors

Linear algebra / Matlab question: in $\mathbb{R}^{3}$, let's say that I have an orthonormal basis, $\{v_{1},v_{2},v_{3}\}$, that is not the standard Euclidean basis vectors, ($e_{1}=(1,0,0)$, $e_{2}=(...
-1
votes
1answer
28 views

Using variable index in matlab [closed]

If we have k=1:n, and then we put k in a function so we get fk=f(tk) for some values of <...
0
votes
0answers
55 views

Integration of multi-valued function

Graph I have a set of discrete (x,y) points and need to find the area between the curve and the y-axis. However, the curve seems to be a multi-valued function (multiple x for the same y). Is such an ...
1
vote
0answers
15 views

outage probs vs number of transmit antenna

Can some one please help me with a matlab code for plotting outage probability against number of transmit antennas in a Massive MI-MO System? i have tried plotting and keep getting single values that ...
0
votes
4answers
37 views

How to create a matrix from an equation in Matlab?

Let A = $(a_{ij})$ be the matrix with entries $a_{ij} = i^2+j^2$ A is a $N\times N$ matrix How can I construct a matrix from this equation?
1
vote
1answer
29 views

Estimating initial conditions of an ODE system using least squares

I am trying to estimate the parameter values of the differential equation, ${dN\over dt}=\lambda N$. I know how to estimate the parameter value of $\lambda$ but I am having trouble in estimating the ...
0
votes
1answer
14 views

Optimal approximation of nonlinear probability density function by piecewise constant density

Given a nonlinear probability density function F, the problem is to estimate F using histogram over a partition with N intervals. I have tried to realise this with MATLAB function fmincon, but it ...
0
votes
1answer
30 views

Bode Phase Plot

I have a simple transfer function, given by: $$ \text T(j\omega)=2\cdot(1-2\text{j}\cdot\omega) $$ I'm attempting to make it's Bode Phase plot without any calculator or program. What i did: $$ \...
0
votes
0answers
12 views

Trigonometric interpolation from DFT on sampled data

I want to interpolate N points on the $[0,2\pi)$ interval using trigonometric functions. Looking at my old notes from university courses, I can build the trigonometric polynomial $$ P(t) = a_0 + \...
1
vote
0answers
28 views

4d Integral in matlab

I'm trying to evaluate the integral using MATLAB with an equation containing 4 related random variables, thus the boundaries of the integrals are not constant. There are 2 exponential pdfs, and 2 ...
1
vote
1answer
36 views

Cubic Bézier radius of curvature calculation

I modelled a racetrack using cubic Bézier curves. I understand that the representation is parametric: x and y vary with t. I have successfully created the cartesian coordinates thanks to this: https://...
0
votes
1answer
65 views

Using Matlab's fmincon to find optimal parameter of SDOF system having discrete white noise input

I am trying to use Matlab's fmincon function to find the optimal value of $k$ for the following ODE, which represents a mass-spring system, $$m\ddot{x}(t)+kx(t)=f(t),$$ where $f(t)$ is taken to be ...
0
votes
0answers
21 views

Plotting phase portrait for a system in MATLAB

I want to plot the phase portrait of the following system in MATLAB, $$\mathbf{X'}=\begin{pmatrix} 1 & 1 \\ 1 & 1\end{pmatrix}\mathbf{X}$$ so far this is the code I wrote ...
0
votes
1answer
34 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: ...
0
votes
1answer
45 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 ...
1
vote
0answers
25 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
40 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
0answers
26 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
34 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
1answer
65 views
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
20 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
10 views

2D Meshing of an Arbitrary Polygon in Matlab

I am trying to create meshing for an arbitrary polygon; such as, ...
0
votes
0answers
13 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 \...
0
votes
0answers
16 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
36 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 ...
1
vote
1answer
163 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
45 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
1answer
47 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
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: ...
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 $...
3
votes
1answer
39 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,...
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
1answer
42 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 ...
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 ...
0
votes
2answers
40 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
45 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 ...