# Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

791 questions
Filter by
Sorted by
Tagged with
1 vote
10 views

• 109
59 views

### Using Implicit Euler Method with Newton-Raphson method

So I'm following this algorithm and here is my attempt: ...
57 views

126 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 ...
• 33
20 views

### How to write a dynamic SDP using CVX?

Consider the following SDP \begin{aligned} \min\quad&\text{tr}(CX)\\ \text{s.t.}\quad&\text{tr}(A_iX)=b_i,\quad i=1,\cdots,p\\ &X\succeq0 \end{aligned} where $C$ and $A_i$ are given ...
• 31
52 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 ...
61 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
110 views

• 11
167 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 ...
• 61
32 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, ...
• 11
143 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 ...
• 23
1 vote
86 views

• 103
56 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 ...
66 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 ...
• 101
129 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$$ ...
49 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 ...
• 101
83 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....
• 23
31 views

### Solving a time-independent 2D Schrödinger equation using PDE Toolbox in MATLAB

I want to solve the following PDE eigenvalue problem, $$-\left(\frac{\partial^2}{\partial x^2}+\frac{\partial^2}{\partial y^2}\right)\psi_n(x,y)+x^2y^2\psi_n(x,y)=E_n\psi_n(x,y)$$ inside a square with ...
• 129
856 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, ...
• 8,553
70 views

• 123
68 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 ...
• 23
1 vote
115 views

• 123
149 views

### Path constraints for state variables - fmincon, ODE45

My problem lies in constraining state variables (look for 23,24,25). I am currently using ODE45 to solve equations and fmincon to find best control variable.How would you go about solving this? Here ...
590 views

### Specifying ode solver options to speed up compute time

I'm specifying the 'JPattern', sparsity_pattern in the ode options to speed up the compute time of my actual system. I am sharing a sample code below to show how I ...
• 581