Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

-2
votes
1answer
206 views

Solving a differential equation using numerical methods and matlab

(a) Consider the following differential Equation $$Y'(t)=\frac{1}{1+t^{2}}-2[Y(t)]^2$$ $$Y(0)=0$$ The exact solution is $$Y(t)=\frac{t}{1+t^2}$$ Using the Euler method to solve the following ...
9
votes
1answer
460 views

Matrix Balancing Algorithm

I have been writing a control system toolbox from scratch and purely in Python3 (shameless plug : harold ). From my past research, I have always complaints about ...
0
votes
1answer
61 views

Solving ODEs of Switched Systems using MATLAB ODE suite

I have the following code to execute: $X$ = [0;0;0;0]; $sw$ = 0; ...
1
vote
0answers
743 views

Nelder-Mead algorithm with constraints

Im currently implementing a Nelder-Mead algorithm in MATLAB that can deal with constraints. In detail, the constraints should be added to the objective function with a Lagrange Multiplier($\lambda$) ...
1
vote
2answers
302 views

Defining a pixel neighborhood in an array in MATLAB

I am working with matrix operations in MATLAB, and I would have the following problem. I have matrix containing zero elements: a=zeros(100,100) and another ...
0
votes
1answer
131 views

fast adaptive quadrature on equispaced 2-D grid

I need to numerically evaluate 2-D integrals of the form: $$ \mathcal{I}(\theta) = \int_{0}^{1} \int_0^1 \varphi_\theta(x,y) dx dy $$ where $\varphi_\theta$ is a family of smooth functions indexed by ...
1
vote
0answers
59 views

Name of third-party Matlab packages for solving PDEs

I am interested in working with systems of PDEs in two spatial dimensions, as part of a mathematical modeling project. The systems of PDEs are coupled, and there is no convenient reduction to 1 ...
0
votes
1answer
790 views

Use Monte Carlo method to simulate consecutive decay in MATLAB

I'm trying to use MATLAB to simulate an atom decay process by using Monte Carlo approach. The process is as follow: Suppose that atom 1 decay to atom 2, which, in turn, decay to stable atoms of type ...
1
vote
0answers
87 views

Adjoint of the MATLAB $\tt dwt3$ (3D wavelet transform) operator

How do I compute the adjoint of MATLAB's dwt3 operator? In other words, how do I compute the adjoint of the linear operator that takes a 3D complex array ...
1
vote
1answer
100 views

Numerical Integration [duplicate]

Let $\alpha=1.714$ and $\lambda=-v(1-v^{\alpha})/\alpha$, where $0<v<1$. Consider $\phi(v)=\exp\{\int_{v_{0}}^{v}\frac{1}{\lambda(t)} dt \}$, where $0< v_{0} <1$ is an arbitrary chosen ...
1
vote
2answers
102 views

Data cloning into 3D matrix

I am working with MATLAB, and I would have the following problem. I have the following matrix of random numbers rand(200,200) and I need to create a 3D matrix ...
0
votes
1answer
157 views

flux limiter problem

I have worked with MATLAB for calculating below equation for any time ($n$) and place($i$). In this equation, flux limiter is used. $$C(i,n+1)=C(i,n)-V\left[1+\frac{1}{2}\psi(r_i)-\frac{1}{2}\frac{1}{...
0
votes
1answer
938 views

Faster code for double integration using Gauss-Legendre quadrature

I came with a the following code to evaluate a double integral using Gauss Legendre quadrature in MatLab ...
1
vote
0answers
157 views

How to form the stiffness matrix for the Poisson equation using a spectral method

This is a follow-up question to How do I form the Chebyshev differentiation matrix in MATLAB? The goal of the following code is to solve the Poisson problem: ...
1
vote
2answers
354 views

Generating 4D Plots in Matlab

I have some data in the form of: ...
1
vote
0answers
59 views

Gauss Seidel moving mesh AMR hamilton Jacobi

I was trying to implement a moving mesh algorithm using Gauss Seidel, so: I have a pde like this (Hamilton - Jacobi eq) $\begin{cases}\phi_t+H(\phi_x)=0 & [-1,1]\times [0,T]\\\phi(x,0)=\phi_0 &...
4
votes
1answer
761 views

How do I form the Chebyshev differentiation matrix in MATLAB?

I have some code that does exactly this, but I do not like to use things I do not understand. Here is the code ...
1
vote
1answer
268 views

How does Matlab `surf` perform interpolation?

When I use Matlab's surf function, I notice that I can't re-perform its interpolation, which produces unreliable results. Do you know what does ...
1
vote
1answer
238 views

Can I model laminar incompressible fluid flow and heat transfer in MATLAB's PDE toolbox?

I have a system of PDEs in cylindrical coordinates that needs to be solved: 1. Continuity equation 2. Incompressible Navier stokes ( in r & z coordinates) 3. Heat transfer equation with both ...
0
votes
0answers
57 views

Cloud computing solution for scientific Calculation software [duplicate]

I am an engineering student and we use a software called ROOT. https://root.cern.ch/ It is used for big data analysis and general scientific calculations, kind of like MATLAB I guess. My problem is ...
1
vote
1answer
168 views

Matlab: Creating a matrix that represents a colored, sinusoidally-modulated grating

I would like to draw a texture (in Matlab - Psychtoolbox) which is composed of a sinusoidally-modulated isoluminant (magenta & cyan) grating. I do have the RGB matrices of the two phases (for ...
0
votes
2answers
150 views

What is wrong with my code for solving Poisson equation with one side Neumann boundary condition?

I wrote a Matlab code for solving 2D Poisson equation $u_{xx} + u_{yy} + f(x,y) = 0$ on $[a,b]\times [c,d]$ with neumann boundary condition on $x = b$ and the other boundary conditions are dirichlet,...
0
votes
1answer
985 views

Solving Time dependent Schrodinger equation using MATLAB ode45 [closed]

The Schrodinger equation for time-dependent Hamiltonian is $$i\hbar\frac{d}{dt}\psi(t) = H(t)\psi(t) \, .$$ I try to implement solve the Schrodinger equation for time-dependent Hamiltonian in ODE ...
3
votes
1answer
395 views

Defining Cauchy principal value in MATLAB (or Scilab/Maple)?

How to define a variable which is an integral involving cauchy principal value inside in any computer programming language? I want to know how to break down the procedure step by step from a ...
3
votes
1answer
138 views

Approximating improper integral with FFT

In d'Halluin et al. (2005) (http://imajna.oxfordjournals.org/content/25/1/87.short) the authors claim that the correlation integral $$ I(x) = \int_{-\infty}^{\infty} V(x+y) f(y) dy $$ can be ...
3
votes
1answer
267 views

Computational time not proportional to integration interval in ODE-solver?

I am running octave and i have been trying ode45, ode54, ode23 etc to integrate the equation ` $$Q''(t) = B\cos(Q)\sin(\omega t)$$ $$Q(t=0)=0.$$ When the time interval to be integrated increases, the ...
1
vote
0answers
85 views

Conservative Short Sales Portfolio Optimization with MatLab code help

I'm trying to solve the optimization problem below with MatLab, but I'm unsure of how to modify the constraints in the quadprog function (or how to add the constraints with the Portfolio object). In ...
0
votes
1answer
634 views

Conjugate symmetry in MATLAB?

I have a large vector with complex numbers. How do I check whether it a conjugate symmetry vector? If not, is there any way to transform it?
0
votes
1answer
92 views

Discretized matrix from the integral kernel function

Recently, I read a paper [1] and then I want to handle the two-dimensional linear integro-differential equation \begin{equation*} -\triangle u + q\Big(\frac{\partial u}{\partial x} + \frac{\partial u}{...
1
vote
0answers
106 views

Stiffness emerges as number of ODEs increases

I want to solve a system of ordinary differential equations with Matlab. I need this to solve a mechanical engineering related problem. If $n$ is the number of degrees of freedom of my mechanical ...
0
votes
1answer
177 views

Nice plot of f(x)

A user has this nice graph of f(x) on his profile and I want to learn how to do it in matlab or Gnu octave. ...
1
vote
0answers
92 views

Difference between Brent's and Alefeld-Potra-Shi for root finding

I need to find the (unique) root of a nonlinear function $f(x)$, $x \in \mathbb{R}$. For the record, $f(x)$ is the CDF of a probability density minus a constant $0 < p < 1$ (I am inverting the ...
1
vote
0answers
291 views

Solving system of constrained linear and non-linear equations in MATLAB

Solving system of constrained linear and non-linear equations in MATLAB I'm solving a FEM problem in MATLAB with use of the direct stiffness method. The problem is now formulated as a system of nn ...
-4
votes
2answers
115 views

How to write a function that its plot is like a “M” in MATLAB

I wrote a code in MATLAB that solves parabolic equation of two space (heat equation:$u_t = u_{xx} + u_{yy}$ )with ADI (Alternating direction implicit) method (finite difference method). Now in order ...
0
votes
1answer
166 views

Integer programming with Matlab

I'd like to know how to solve in MATLAB the following integer optimization problem : $\underset{B,D}{\arg\min} \Vert{Y-XDB}\Vert_{2}$ where $X,Y$ are given matrices. The constraint is the following ...
-1
votes
2answers
267 views

Stability of matrix equations in MATLAB

Is there a method to check for unconditional stability or positive-definiteness of large matrices in MATLAB? For example, I know that matrices with property M (positive main diagonal elements and ...
8
votes
0answers
130 views

Tucker factorisation to compare multiple PCA decompositions?

This is an entry-level question for multiway matrix decompositions. I have a set/population $k$ of entities (here biological cells) for each of which I also have a number ($l$) of flavours of length $...
0
votes
1answer
718 views

COMSOL: get list of eigenfrequencies [closed]

In COMSOL, is there a way to get it to export a txt file with all the eigenfrequencies found during an eigenfrequency analysis? I suppose that it could be done through the MATLAB interface or through ...
1
vote
1answer
638 views

How to solve the problem without using symbolic computation

I have the following simple nonlinear equations with two unknowns only: $$\left\{ \begin{array}{c} \int_1^2{\dfrac{ e^{{a_1} x+{a_2} x^3}}{1+x^2}} \, dx=1 \\[13pt] \int_1^2{ x^2 e^{{a_1} x+{a_2} x^...
0
votes
2answers
673 views

Difference between Data structure objects and cell array objects in matlab

I want to know what are the differences between two data structures in MATLAB: Structure Arrays and Cell Array. In what circumstances we can use each of them?
1
vote
0answers
73 views

Need help writing the code for the following optimization

I need to find $X$ for which the following expression is minimized: $$ \min ||Y - F^{-1}(X)||_2 + ||X||_1 $$ where $Y$ is an array (of length approx 44000, an audio sample I will be reading using ...
5
votes
0answers
137 views

Galerkin FEM error when using even number of elements

Intro: I am developing a Galerkin FEM code in matlab - starting small with a simple 1D ODE. The equation I'm trying to solve is: $$a u_x = cos(x), x \in [0, 2\pi]$$ Which has a known exact solution $$...
1
vote
0answers
164 views

Numerically computing Viscous Burger

I am trying to solve the Viscous Burgers equation using the spectral method. $$u_t+uu_x = Du_{xx}$$ where $D$ is a constant (chosen to be zero) and with the initial condition $$u(x,0) = exp(-x/0.2)^2$$...
3
votes
1answer
577 views

Numerically computing the advection equation

I am trying to write a program to compute the advection equation. $$u_t +u_x = 0$$ I use the spectral method for the spatial derivative $u_x$ and the leapfrog method for the time derivative $u_t$. ...
1
vote
1answer
67 views

Handling figures built for different parameters in Matlab

I couldn't find a simple answer to this thing I'm trying to do in Matlab. I have a function file that does some calculation for a given parameter a: ...
1
vote
0answers
111 views

Scaling a vector-valued non-linear function for numerical optimization/minimization

I am trying to minimize a non-linear vector-valued function in MATLAB. As a test case for my code, I try to minimize a function whose solution I know apriori. The problem is that one of the ...
1
vote
2answers
51 views

MATLABs double arithmetic

this is a classical problem, but I need help to pinpoint what I am missing. Problem: In MATLAB (exp(1) + 10^12) - 10^12 gives you a double which equal to e, up to 5 correct digits. But I thought ...
0
votes
0answers
541 views

How to solve a set of 1st order 1D PDEs in Matlab?

i have already asked something similar to this once but sadly i wasn't able to get a complete answer, so i remain stuck on this problem. the Matlab function pdepe seems to only be able to solve 2nd ...
1
vote
2answers
2k views

Code for shallow water equation

I want to write a MATLAB code for Roe solver for 1D shallow water equations. Is there anyone who can help me with that?
1
vote
1answer
351 views

Matlab integral with vectorized bounds, without using a loop

I have a simple question that I wasn't able to find an answer to. I have a function f(x) where x is some vector, for example: <...