Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
1 vote
2 answers
88 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/...
user8469759's user avatar
2 votes
0 answers
31 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 ...
Xingda Chen's user avatar
2 votes
2 answers
168 views

Reordering eigenvalues in Schur factorization - MATLAB orschur 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 <...
two_Thomas's user avatar
0 votes
0 answers
71 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 ...
AgentOrange's user avatar
1 vote
0 answers
66 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 ...
user45844's user avatar
0 votes
0 answers
64 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....
Piotr's user avatar
  • 1
0 votes
1 answer
37 views

'Integral2' error in MATLAB for invalid integrand

Here is the code that I am trying to run: ...
vidyarthi's user avatar
  • 111
0 votes
2 answers
62 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 ...
dazemood's user avatar
3 votes
1 answer
172 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 ...
user45844's user avatar
0 votes
0 answers
55 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 ...
AgentOrange's user avatar
0 votes
2 answers
150 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 ...
Neuling's user avatar
  • 23
3 votes
3 answers
164 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 ...
Alex Cage's user avatar
1 vote
0 answers
45 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 ...
Yashab Yadav's user avatar
3 votes
1 answer
156 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}...
B0bby31's user avatar
  • 33
0 votes
1 answer
114 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:...
Walden Marshall's user avatar
4 votes
1 answer
130 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....
eepperly16's user avatar
1 vote
0 answers
38 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)\...
blockchain187's user avatar
0 votes
0 answers
80 views

Best approach to solve this system of equations?

I have the following 1D (in space, that is) system of equations I would like to solve: \begin{equation} \rho_{fs}\frac{\partial x_{fs}}{\partial t} = h_m\left(W_a - W_{fs}\right) - D_{eff}\left(\...
HVdB's user avatar
  • 9
0 votes
0 answers
40 views

Model the water vapor fraction of a humid air inside a tower

I am going to model the moisture air inside an energy tower, therefore. I formulated the following equation to calculate the fraction of water vapor, Y in the moist air, where $\rho_w$ is the water ...
TMW's user avatar
  • 11
1 vote
0 answers
66 views

Discrete laplacian 9 point

I am trying to write a code for 9 point discrete laplacian. I would like to write a matrix and solve the linear system $AU=F$ with gradient conjugate method. I wrote the matrix this way ...
Cristie's user avatar
  • 41
3 votes
1 answer
89 views

Upwind scheme with periodic conditions

I am struggling with this assignment. I have to write an upwind scheme for the following PDE: $$u_t+a Du=0 \quad\mathrm{on}\;(-1,3)$$ $a$ is said to be positive, the initial condition is $\sin(2\pi x)$...
Cristie's user avatar
  • 41
0 votes
1 answer
114 views

Solve discontinuous ODE with lsode

I am trying to solve a discontinuous ODE using the lsode solver. I tried setting the t_crit parameter to specify the time where the discontinuity is present, but it ...
Bruno's user avatar
  • 101
2 votes
1 answer
63 views

Solving constrained odes's using inbuilt solvers in Matlab/Octave

I would like to solve a set of coupled second order differential equations using inbuilt Matlab/Octave subroutines. These equations arise when trying to model sliding of mass ($m_2$) over a wedge of ...
Salil S. Kulkarni's user avatar
0 votes
1 answer
124 views

How to speed up sparse matrix index operation in Matlab?

I need to create spare matrices with variable elements. Unfortunately, sparse matrix index operations are very slow. Is there any way to speed up the process? Maybe there are some tricks that I don't ...
Kim's user avatar
  • 21
0 votes
1 answer
61 views

Numerical solution of PDE with uniform initial condition

I have a PDE like this $$ \frac{\partial h}{\partial t} = \bigg(\frac{\dot{L}}{L}\bigg)x\frac{\partial h}{\partial x} - \alpha\bigg[h^3\frac{\partial^3 h}{\partial x^3}\bigg] $$ With boundary and ...
dazemood's user avatar
1 vote
0 answers
163 views

Magnetic field simulation for "quasi-solenoid" - Where to start?

I would kindly ask you which (preferably free) programs / codes do you suggest for the numerical simulation of the problem described below. I am not asking for the full solution, but just want to ...
t387's user avatar
  • 11
3 votes
2 answers
813 views

My Complex Matrix SVD is Correct according to rule A = USV' but Wrong according to Matlab or any linear algebra library

I am working on Singular Value Decomposition for complex matrices. I implemented One Sided Jacobi algorithm. It gives exactly the same result as the svd function in Matlab for the real matrices. ...
Emir evcil's user avatar
0 votes
1 answer
117 views

Solving PDE with a non-linear constraint in MATLAB

I am trying to solve a DAE with a non-linear constraint. The governing equations have the following form. The second equation is a constraint and it must be satisfied everywhere. Is there a way to ...
penghao zhang's user avatar
2 votes
1 answer
371 views

Numerical solution of 2D wave equation using Fourier transform and finite differences

This is the $2$-dimensional wave equation $$ u_{tt} = u_{xx} + u_{yy} $$ with initial condition $u(x,y,0)=f(x,y)$ and $u_{t}(x,y,0) = 0$. The inverse Fourier transform used is $$ u(x,y,t) = \iint \hat{...
Redsbefall's user avatar
3 votes
0 answers
154 views

Numerically solving a 6th order non-linear differential equation in Matlab

I've posted yesterday a question about solving a non linear equation : it was not clear so I am reformulating my question. I am trying to solve a high-order non linear differential equation presented ...
Wiss's user avatar
  • 33
-1 votes
1 answer
127 views

The local and average Nusselt number in a square cavity

I am in the process of programming the local & average Nusselt number in a left vertical wall but my Matlab script gives me inappropriate values and it doesn't change with changing of Rayleigh ...
Bakizza's user avatar
2 votes
0 answers
131 views

Generalized Eigenvalue Problem using MATLAB

I'm trying to solve a generalized eigenvalue problem. I have two matrices $H$ and $S$ such that: $$ HX=λSX $$ I need to find the eigenvalues $\lambda$. The matrices $H$ and $S$ are real, asymmetric, ...
Beginner Noob's user avatar
1 vote
1 answer
232 views

What does the Chebyshev differentiation matrix look like for third and fourth derivative?

I have a PDE that contains both the 3rd derivative and 4th derivative. Example shown below $$ \frac{\partial u}{\partial t} =\frac{\partial}{\partial x}(u^3\frac{\partial^3u}{\partial x^3}) $$ $$ \...
dazemood's user avatar
2 votes
1 answer
138 views

Numerical diagonalization of Hamiltonian

Framework I am trying to diagonalize the Bogoliubov-de Gennes Hamiltonian. The problem is that the Hamiltonian contains a Laplacian. This could be solved by using a discretized Laplacian. How I tried ...
Guest's user avatar
  • 21
0 votes
1 answer
109 views

Assembly of the Isoparametric Quadratic load vector in Matlab [duplicate]

I work to solve PDE using FEM in the case P2 on Matlab. I try to correctly assemble load vector using quadratic Lagrange shape functions $$b_i =(f,\phi_i)=\sum_{q=1}^{nq}f(r_q,s_q)*\phi_{i}(r_q,s_q)*...
A. AchbK's user avatar
4 votes
1 answer
329 views

How can I solve a pde with second derivative boundary condition?

I have an equation like $$ \frac{\partial u}{\partial t} =A\frac{\partial^4u}{\partial x^4} $$ with boundary condition $$ u(x = \pm L,t) = 9; u_{xx} (x=\pm L,t) = 4 $$ I tried to use the method of ...
dazemood's user avatar
1 vote
2 answers
337 views

Calculating Lyapunov exponent (LE) for pendulum using ellipsoid growth - code yields negative LEs

I was redirected here from physics stack exchange where hopefully my question is more appropriate. Per my advisor, I have read the textbook Chaos, an introduction to dynamical systems by Alligood, ...
t-osu's user avatar
  • 21
2 votes
1 answer
512 views

Why is my Runge-Kutta 4 solution to the 1-D advection equation decaying so quickly?

I am trying to numerically solve the advection equation $y_t + y_x = 0$ using a the "classical" Runge-Kutta 4 explicit timestepping method, along with a left-hand finite difference ...
bosco98's user avatar
  • 23
1 vote
0 answers
217 views

How to discretize PDEs using Chebyshev spectral method into a system of differential algebraic equations (DAEs)?

Let's take the heat equation. We have a time derivative and spatial derivative. How to discretize the spatial derivative using Chebyshev spectral method and convert it into DAEs? Like in the form of $ ...
dazemood's user avatar
0 votes
1 answer
55 views

Numerical Error source when dealing with integer series

I am currently trying to compute the value of the first Fibonacci number recursively. the idea is as follow: Compute $f_{n}$ and $f_{n-1}$ for $n = 2,...,100$, Compute $f_k$ for $k = n−2, n−3, \dots, ...
devCharaf's user avatar
  • 103
2 votes
0 answers
93 views

Cyipopt fails to converge for NLP problem which fmincon() can solve

I'm currently trying to implement a python script for solving a constrained nonlinear optimization problem with ~800 variables and 2 constraints, one linear and one nonlinear. There already exists a ...
Bobbybobbobbo's user avatar
0 votes
1 answer
113 views

How to remove singularit​ies/discon​tinuities on 3D plots in Matlab?

I want to plot some functions f(x,y) including singularities. For example; f(x,y)=tan(x-y) In Matlab, when I run the following code ...
1_student's user avatar
  • 101
1 vote
1 answer
488 views

Solving ODE with Spectral Method using Chebyshev Polynomials

I would like to solve following the basic equation of linear elasticity (for simplicity in 1D) $$ \frac{d}{dx} \left( E \frac{du}{dx} \right) = 0 \quad \textrm{with} \quad u(1)=0, \; u(-1)=b $$ ...
PS-Elas's user avatar
  • 13
0 votes
1 answer
59 views

why is $Hx= x-2u^{H}xu$ ? why not $Hx= x(x-uu^H) + 2((u^Hx)u)^2? $

I have some confusion in this diagram My confusion : why is $Hx= x-2u^{H}xu$ ? why not $Hx=x(x-uu^H) + 2((u^Hx)u)^2? $ My thinking is that by using pythogoras theorem blue line(vector) denotes ...
user12392's user avatar
  • 101
2 votes
1 answer
302 views

High precision numerical integration of discrete data with Matlab

I have discrete data of a function plotted below: The "Y" values of the function near "X=1.57" are very close to each other and zero, like 9.25558265263186E-11 and 5....
tio's user avatar
  • 23
11 votes
2 answers
1k views

Why is RK45 used as the "default" method for non-stiff ODEs rather than a multistep one?

From what I read, the "default" go-to method for non-stiff ODEs is the Dormand-Prince Runge-Kutta pair; for instance, in Matlab docs, "Most of the time, ...
Federico Poloni's user avatar
2 votes
2 answers
83 views

Possible to use Iterative FD methods to solve a transformed non square domain [matlab]?

For the 2-D Poisson equation $$-(u_{xx}+u_{yy}) = f \ \ \text{where} f = 1$$ For boundary conditions $$\frac{\partial u}{\partial n} = 0 \ \text{on AB and AD}$$ $$ u = 0 \ \ \ \text{on BC and CD no-...
bc_eng's user avatar
  • 23
0 votes
1 answer
118 views

Time & Space matlab discretization Finite Differences confusion

I have been trying to solve this equation and write the finite difference scheme in matlab for months, but I still am not successful. Given the KdV Equation $$\tag{1}u_{t} -6uu_x+u_{xxx}=0$$ I have ...
bc_eng's user avatar
  • 23
2 votes
0 answers
378 views

Numerical evaluation of Duhamel's integration

I am trying to numerically evaluate the following Duhamel's integration: $$ x = \frac{-1}{\omega_d} \int_0^t \ddot{x}_g (\tau) e^{-\zeta \omega_n(t - \tau)} \sin{\left( \omega_d (t - \tau) \right)} d\...
Quang Thinh Ha's user avatar
3 votes
1 answer
137 views

Mineral dissolution and solute transport around a solid

I am trying to simulate solute transport of acid (HCl) and consequent mineral dissolution around a grain (calcite). The governing equation for transport is the advection-diffusion equation, given as: ...
oma11's user avatar
  • 55

1
2 3 4 5
17