# Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

812 questions
Filter by
Sorted by
Tagged with
1 vote
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/...
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 ...
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 <...
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 ...
1 vote
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 ...
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....
37 views

### 'Integral2' error in MATLAB for invalid integrand

Here is the code that I am trying to run: ...
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 ...
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 ...
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 ...
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 ...
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 ...
1 vote
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 ...
156 views

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 ...
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 ...
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, ...
1 vote
232 views

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 ...
1 vote
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, ...
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 ...
1 vote
217 views

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 ...
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 vote
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$$ ...
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 ...
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....
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, ...