Questions tagged [matlab]
Questions about the numerical programming language MATLAB.
845 questions
0
votes
1
answer
97
views
Scaling of a matrix based on leading order terms
I am working in computational mechanics and I am working on a semi analytical solution for fracture in curved thin shells. I am implementing the solution in Matlab.
TL;DR: are there strategies to ...
0
votes
1
answer
86
views
How to transform the matrix into a specific form
Consider a full-row rank matrix $A \in \mathbb{C}^{r \times n}$ (where the number of rows r is less than the number of columns n). How can we find a column permutation or an invertible transformation ...
0
votes
0
answers
37
views
Matrix transformation [duplicate]
Consider a full-row rank matrix $A \in \mathbb{C}^{3 \times 7}$,How can we find a column permutation or an invertible transformation T such that TA has the following form:
$
\left[
\begin{array}{...
0
votes
0
answers
51
views
MATLABcode in 'the paper Explicit estimates for the Riemann zeta function close to the 1-line'
I’m reading the paper Explicit estimates for the Riemann zeta function close to the 1-line (arXiv:2312.09412), and on page 6, the authors define the following expressions:
$w_1 \geq max _{t\geq t_0}\...
2
votes
1
answer
136
views
Computing a double-sum in MATLAB
I have a solution vector
$$\begin{equation}H^{(\text{LR})}:= \frac{1}{\Delta x^{2}}\sum\limits_{n=1}^{N}\sum\limits_{m=1}^{N}\frac{u_{n}u_{n+m} + v_{n}v_{n+m}}{m^{1+\alpha}}\end{equation}$$
where $u_k$...
0
votes
1
answer
83
views
Advection Diffusion in a 1D pipe with no inlet or oulet
My scenario is that a pipe is full of a fluid (similar properties of water). A solute is introduced to the inlet at time t=0 and given time to disperse throughout the pipe. The solute cannot leave and ...
1
vote
0
answers
78
views
Does the method of moments works for wave-length dipole?
In Constantine A. Balanis book about Antenna, he introduced the method of moments for current distribution over finite dipole.
However, I found that the method of moments works well for a half-...
0
votes
0
answers
63
views
How to connect two surfaces to create a solid on MATLAB?
So I have this code where I am creating two surfaces using zernike coefficients and polynomials. Now I want to connect them and make it as a solid object. How can I do that in Matlab? The ...
1
vote
0
answers
68
views
Boundary Value Problem for an Indeterminate Beam using Finite Difference Method
I hope I am in the right place!
I am trying to solve an indertminate beam using the finite difference method in MATLAB. I am using the fourth order equation to do this:
enter image description here
My ...
1
vote
1
answer
98
views
Imposing optimization constraints on linked variables
Say I have a discrete non-linear programming problem,
$$ \min_\textbf{x} \quad \Sigma^N_{n=0} J(\textbf{x}_n)$$
with $\textbf{x}_n = [x_1, x_2]_n$, and some non-linear constraints on $x_1$ and $x_2$. ...
2
votes
0
answers
76
views
MATLAB `ordschur` producing different results from Lapack's `dtrsen` in Simulink
My question is very similar to the one previously posted here. I'm using the same MATLAB code for embedding Lapack functions into my code, which I also compiled with Mingw64. The main difference is ...
4
votes
3
answers
229
views
Is there any matlab built-in function or libraries to calculate $\frac{d(\ln A)}{dA}$?
we can first conduct spectral decomposition of an positive definite isotropic tensor $A$ and then we can define $\ln(A)$, then we can define the frechet derivative of it, but how to calculate this in ...
2
votes
0
answers
137
views
2D cavity flow: Adding zero Dirichlet condition to the top boundary leads to NAN
I am following this guide to create a simple cfd solver for incompressible 2D fluid in a square cavity. The following Matlab code sample from the guide creates a Laplacian (coefficient) matrix with ...
0
votes
0
answers
56
views
A plane or surface passing through two surfaces in MATLAB
I have just been able to plot several surfaces using the code below. What I want is a plane or a surface that connects the black and yellow region in the output of the code below:
...
2
votes
1
answer
96
views
What would be the right approach to numerically integrate in MATLAB an improper integral with Bessel function?
I have an improper integral which contains Bessel functions, Cosine term as well as a rapidly decreasing exponential term. This is the integral:
$$\frac{1}{2\alpha}\int_{0}^{\infty}e^{-\frac{\xi^2}{4\...
1
vote
1
answer
148
views
'eigs()' in Matlab gives inaccurate eigenvector when only several eigenvalues are calculated
I would like to report an issue which may be interesting in computational physics. Sometimes, to save time and memory, we use eigs() to calculate the first several ...
0
votes
0
answers
66
views
Prof A. Stanoyevitch's finite difference based PDE matlab code
Where can one find Prof A. Stanoyevitch's finite difference based PDE matlab code? They have a book on such a topic but can't find the accompanying code.
Is it well received? It's not commonly talked ...
1
vote
1
answer
146
views
Educational Purpose: How to synchronize chaotic systems
The graph plots the X coordinate of the synchronized Lorenz chaotic system. I am self learning by reading research articles on how to synchronize identical chaotic systems. But as seen from the figure,...
0
votes
1
answer
125
views
Prof Lawrence Shampine's hpde matlab code
Where can one find Prof Lawrence Shampine's hpde matlab code?
Is it well received? It's not commonly talked about.
0
votes
0
answers
48
views
How to stop loops or close figures in live scripts in matlab
I wanna use matlab live scripts to run a loop updating an animation because this will allow to playback the animation. In the normal command window or m files one can use uicontrol to stop loops or ...
0
votes
1
answer
133
views
ode23, 45, 15s, 15i in matlab for conservative ODEs
Which of ode23, 45, 15s, 15i in matlab are dissipative or anti-dissipative for conservative ODEs?
Do they STAY dissipative or anti-dissipative for ALL conservative ODEs nor not? If not, what about for ...
1
vote
1
answer
104
views
Multivariable Newton's method for-loop
I am struggling with an assignment concerning Newton's method. We are to approximate 3 intersection points using intersecting circle coordinates P1, P2 and P3, using Newton's method. And I can do that ...
0
votes
1
answer
111
views
shooting method to compute the interface shape
I am trying to use a shooting method to compute the shape of liquid-gas interface given by the following differential equation:
$$
\frac{d^2 \theta}{ds^2} = \frac{f(\theta)}{h(h + 3\lambda)}
$$
with $\...
0
votes
0
answers
79
views
Help with inferring Network topology from Spectral templates
I am trying to use matlab and YALMIP to solve a graph learning problem of recovering eigenvalues from the eigenvectors of the covariance of sampled graph signal data. This is to implement the ...
1
vote
1
answer
205
views
Step size constraint in Euler backward
I am dealing with an assignment in MATLAB. It has to do with 'self-driving' cars which are driving in-front/behind eachother. Assuming M cars on a single-lane road, each car adjusts its speed based on ...
0
votes
1
answer
164
views
How to plot the power spectrum
I have an array of data whose columns are solution vectors to a system of ODEs at a specific time. I want to plot the power spectrum of a solution at a specific time, but when I attempt this I get ...
4
votes
0
answers
146
views
FVM for non-regular domain with triangular mesh
Setup
The 1D convection-diffusion equation is given by:
\begin{equation}\tag{1}
\frac{\partial u}{\partial t} + v \frac{\partial u}{\partial x} - \mu \frac{\partial^2 u}{\partial x^2} = 0,
\end{...
1
vote
1
answer
132
views
enough conditions to check that a matrix doesn't have Cholesky factorization while factorizing it
I wrote this code to find Cholesky factorization of a symmetric positive definite matrix in MatLab:
...
9
votes
3
answers
4k
views
More stable algorithm to calculate `sqrt(a^2 + b^2) - abs(a)` in MatLab
Suppose we want to calculate $\sqrt{a^2+b^2}-|a|$ in MatLab. Using sqrt(a^2 + b^2) - abs(a) will have some problems:
If a or <...
1
vote
0
answers
128
views
Method of lines for a mixed PDE
I am trying to solve the following PDE using the method of lines to discretize space, and then solve it as system of ODEs at each point in space using ODE15s:
subject to
and initial condition $w(z,t=...
2
votes
0
answers
89
views
Complex matrix logarithm discontinuity by solving inverse Fourier integral by alternative method to FFT
NOTE: This code is a piece of code I am using for a master's thesis, so I do not expect someone to do the work for me, but I gladly accept suggestions of any kind.
However, I am trying to get the ...
0
votes
1
answer
146
views
How can I find the current for a nonlinear electrical circuit using the Shockley equation, in Octave?
For this electrical circuit:
The voltage $ V_D $ can be found by solving a nonlinear equation:
$$ \frac{V_{DD}}{R} - \frac{V_D}{R} - I_se^{V_D/V_T} = 0 $$
In this example, let $R=1000$, $V_T = 0.025$,...
2
votes
1
answer
271
views
Using Sundials CVODE in MATLAB
I'm currently using ode15s to solve a set of stiff differential equations.
I am trying to use the MATLAB profiler to understand the section of the ode solver code which calls BLAS routines.
Since the ...
1
vote
2
answers
272
views
Matlab eigs function with function handle
I am reading through the documentation of matlab function eigs specifically the function handle input version.
Here it is: https://www.mathworks.com/help/matlab/ref/...
2
votes
0
answers
108
views
In electromagnetic simulation, how much does the feed model impact an antenna's directivity performance and E-field phase readings?
Question: How much would a simplified feed model in an EM simulation alter an antenna's directivity and the E-field phase reading when compared to using a more complicated/realistic feed model?
I am ...
4
votes
3
answers
345
views
Reordering eigenvalues in Schur factorization - MATLAB ordschur and LAPACK dtrsen not producing the same results
Disclaimer: I previously posted this on SO, but though it would be more relevant for scicomp. The original post has been deleted.
I have been trying to recreate the functionality provided by MATLABs <...
0
votes
0
answers
100
views
Appropriate values for fluid-structure interaction model using finite element method in MATLAB
I'm having a program to compute the solution for a fluid-structure interaction model (blood and blood vessel walls) using FEM in MATLAB. The program is running fine but the function that I'm ...
1
vote
0
answers
127
views
Optimal Krylov subspace dimension and iteration limits for eigs
When using the eigs function in MATLAB, which is based off of ARPACK, one can manually modify the maximal dimension of the constructed Krylov subspaces, the maximum iteration counts, and the error ...
0
votes
0
answers
102
views
How to get damping matrix for structural model in FE analysis
I need to implement in C a method of obtaining transient solution of damped FE models based on modal results for a structural model (imported CAD geometry) defined with hysteretic (structural) damping....
0
votes
1
answer
78
views
'Integral2' error in MATLAB for invalid integrand
Here is the code that I am trying to run:
...
0
votes
2
answers
161
views
How to remove triangles in a hollow hemisphere shape?
So I have this code where I am designing a hollow hemispherical shape and I want to create a 3D volume to input it into FEBio software.
I am using delaunay triangulation for meshing. But the problem ...
3
votes
1
answer
710
views
Generalized eigenvalue problem for large, potentially ill-conditioned systems
Say that I have a generalized eigenvalue problem of the form $$Ax=\lambda Bx.$$ Using MATLAB, some naive ways that one may solve this is by either
directly inverting $B$ then applying the ...
0
votes
0
answers
81
views
Plot 2D piecewise function in MATLAB
I'm trying to use this method Plot 2D piecewise constant in matlab in a finite elements mesh for my data. However, I have problems with the values of n1, n2 and n3. I guess this is why it doesn't show ...
0
votes
2
answers
218
views
Rotation of Higher order Tensors
I have a $D$-way tensor of dimensions $n\times n \times \dots \times n$ $(D)$- times. I want to sum the First vectors in all directions. For example, let $\boldsymbol{H}$ is 3-way tensor of dimensions ...
3
votes
3
answers
266
views
Unable to calculate binomial coefficients correctly in matlab
I tried to compute the value of the following expression in Matlab:
$$
2^l\sum_{i=0}^{n-1}{N\choose i}\varepsilon^i(1-\varepsilon)^{N-i}
$$
where $N=16272$, $n=499$, $l=107$, $\varepsilon=0.02$.
I ...
1
vote
0
answers
90
views
Need help implementing finite difference Beam Propagation Method to Solve 2-D Helmholtz equation
I am trying to implement beam propagtion method in a two-dimensional lattice to solve Helmholtz equation by following the scheme given this paper. I am using Matlab for implementation.
The expected ...
3
votes
1
answer
219
views
Numerical scheme for the level set equation that solves inverse mean curvature flow problems
I am considering the problem of simulating the evolution of an interface given as a curve in 2D (or surface in 3D) that evolves according to a velocity specified at the interface of the form:
$$\vec{v}...
0
votes
1
answer
247
views
How do I use pdepe for a first order parabolic PDE with only one boundary condition?
I am trying to use Matlab's pdepe.m to solve the first order parabolic PDE
$$\frac{\partial u}{\partial x}+\frac{\partial u}{\partial x}=x$$
I have not had trouble coding the argument of pdepe @pdefun:...
5
votes
1
answer
275
views
Eigenvalues of diagonal plus rank-one
I need to compute an eigendecomposition of an $n\times n$ matrix
$$
D + c vv^\top = Q\Lambda Q^\top \tag{1}
$$
in MATLAB, where $D$ is a real diagonal matrix, $c$ is a scalar, and $v$ is a real vector....
1
vote
0
answers
84
views
Sampling points from space based on known density
I have a problem where I heavily need to restrict the number of points at which I sample a function based on the values of a different function.
I have two functions:
$f:{\mathbb{R}\times [0,\infty)\...