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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions about the numerical programming language MATLAB.

0
votes
0answers
6 views

Synchronization of chaotic neural networks

I am trying to plot the graph of chaotic impulsive neural networks and I have written the following MATLAB code for the same: However, I am getting the Warning: Failure at $t=4.831354$. Unable to ...
3
votes
1answer
75 views

How does fmincon in MATLAB calculate gradients?

I am trying to solve numerically a constrained optimisation problem in MATLAB, and I am wondering how the fmincon function calculates gradients when one isn't ...
0
votes
1answer
34 views

Matlab parpool on Intel Xeon-Phi (KNL)

I am trying to run my matlab script on a Xeon Phi node with 68 physical cores. Using parpool I allocate 16 cores to enable SMD parallelization with a parfor loop. The script looks something like this. ...
0
votes
0answers
37 views

Need an explanation of setting Boundary Condition in pdepe (PDE Solver)

I am trying to solve the Advection-Diffusion equation using pdepe (PDE solver) in Matlab. I am not clear why we are writing ...
2
votes
0answers
99 views

Accelerate computation speed by using a different syntax [closed]

I was reading a book about Matlab ("Accelerating Matlab with GPU computing - A Primer with Examples" by Jung Suh and Youngming Kim, 2013. Chapter 1.7 Examples). I read an example where it said that: ...
6
votes
2answers
163 views

Nonlinear eigenvalue problem - MATLAB code

I'm trying to solve a nonlinear eigenvalue problem in MATLAB, still without success. It's a problem about graphene plasmonics. The nonlinear eigenvalue problem is given below: \begin{equation} \frac{...
5
votes
2answers
164 views

Matrix multiplication accuracy Matlab vs Python

I am translating some Matlab code into Python and I having some problems regarding matrix multiplication accuracy. Assuming we have following data: ...
0
votes
1answer
64 views

How to simulate thermal expansion in a 2D plane using FEA?

I am trying to model 2D thermal expansion of a square area inside another square using FEATool. I have simulated plane strain by incorporating forces pointing along the $[1 \,\,\, -1]^T$ direction ...
0
votes
0answers
23 views

frequency response duffing parameter

Im trying to solve ODE with a duffing parameter $x^5$. I need to plot the frequency responce by using MATLAB. I have the following function: ...
0
votes
1answer
61 views

Prescribing variables as an excitation in Runge-Kutta method

I am using Runge-Kutta to solve a $3 \times 3$ 2nd order linear ODE $$M x'' + C x' + K x = 0$$ and initial conditions are all zeros. Then I prescribe the 2nd variable to follow a given path. As for ...
0
votes
0answers
47 views

How do I “push” matlab's lsqr solver to a particular solution?

The background to my problem can be found here: Iteratively solving a sparse, ill-conditioned system I have a function that now works well. When I give it test data, I recover the expected result. ...
0
votes
0answers
45 views

Methods for Parameter Scaling in Gradient-based Optimization

I am trying to minimize an objective function with 4 parameters, e.g., $a,b,c,d$ using gradient descent. $a < 0.1$, while $0 <b,c,d < 10$. I'm using a learning rate for all parameters on the ...
3
votes
0answers
88 views

Iteratively solving a sparse, ill-conditioned system

I have a sparse (density = 0.2%), ill-conditioned system that I am trying to solve, with no luck. Background I have a sequence of sampled data, where two of every 8 samples have been zeroed due to a ...
0
votes
0answers
38 views

Applying base excitation to a MATLAB state-space

I have a state space model that was provided to me by exporting it from an external FEA program. The model can be described as $\dot x = Ax + Bu$ $y = Cx + Du$ This model assumes forces and ...
1
vote
1answer
37 views

System of ordinary differential equations - time complexity of initial value problem

I am interested in knowing what the time complexity is (in Big-$\mathcal O$ notation) for solving system of $N$ differential equations? I am using ode15s in ...
4
votes
0answers
46 views

Methods to implement floor dirt detection algorithm

I'm trying to detect dirty floor areas in a series of images, using MATLAB and its Image Processing Toolbox, like the one that follows: In the image above, there are two distinct areas, the whiter ...
0
votes
0answers
14 views

Determine the transformations of 3D planes

Basically I have two planar datasets, I have to determine the transformation parameters of it, i.e, translation and rotation. How to perform this? Do I need to do plane fitting for both data at first ...
0
votes
1answer
90 views

Discontinuous Galerkin - Inhomogeneous Dirichlet B.C. for 1D Poisson Equation

I am trying to get some code working for the 1D Poisson equation using the textbook: Nodal Discontinuous Galerkin Methods Algorithms, Analysis, and Applications. I use the following formulation (for ...
0
votes
0answers
67 views

Julia--background code for “jacobi” and “gauss_seidel”

Considering the system below, I can solve it by both Jacobi's method and Gauss-Seidel's method. I know there are pre-made functions for both in Julia, which is what I used, but I'd like to to see ...
3
votes
1answer
46 views

How to preserve or recover states meanings in canonical state-space realizations

Let assume that one would like to translate an input-output model, into a state-space one. It is well-known that the process of realization addresses this aspect. Let assume to have the following ...
0
votes
0answers
32 views

Use Slepc from Matlab

Is there a direct way to use SLEPC from Matlab? I remember that in some old manuals there was some Matlab interface. However, in the last one, I cannot find any reference to this. For me it would be ...
0
votes
1answer
76 views

temperature profile on axial direction of a chamber

I have a task to plot average temperature profile at each cross-section in the axial direction of a combustion chamber. I have $x$, $y$, $z$ coordinates data in excel as well as the corresponding ...
0
votes
1answer
48 views

Anyone who knows fine neural network code or module for python?

I want to change my main platform from Matlab to Python due to my work, and I mainly used Matlab for the neural network, so I want to do the same thing in the Python either. I used to make my own ...
4
votes
2answers
135 views

MATLAB Matrix Multiply Efficiency

I am using MATLAB to prototype a few matrix multiply techniques and compare efficiency. Eventually, I will move the prototype codes to C. It is for a homework assignment where we need to write an ...
1
vote
0answers
130 views

Potential gain - Matlab vs C/C++ - assembly and eigenvalues

I have a Matlab code computing the solution to an eigenvalue PDE. It consists of two parts: assembly of the stiffness/rigidity matrices and solving a generalized eigenvalue problem. I mention that the ...
0
votes
1answer
67 views

Finite difference method for the electric field of the electron gun

Can anybody help me to find books or MATLAB code examples for solving electric field of the electron gun(fig.1)with finite difference method? Python code examples are also perfect. The electron gun ...
0
votes
2answers
63 views

Finite difference for 2nd order ode $y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=0$ with $y'(1)=0$ and $y(1)=1$

How to solve second order non-linear ODE $$y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=0$$ subject to $y'(1)=0$ and $y(1)=1$ over the interval $0 < x \le 1$. I turned the equation to a PDE $y'^2+y y''+\...
3
votes
2answers
225 views

Polynomial Interpolation with Matlab polyfit

Given $N$ data points, does polyfit of degree $N-1$ produces the unique interpolating polynomial? For concreteness, here is a code example: ...
1
vote
0answers
49 views

scaling in discretized PDE system

I want to solve the following system via Matlab $\Omega=(0,1)^2$ $$\Delta y=\frac{1}{\alpha} p$$ $$ -\Delta p= y -1 $$ $$p|_{\partial \Omega}=0,~y|_{\partial \Omega}=0$$ using ...
0
votes
1answer
50 views

Matlab backslash reordering algorithm

For the linear system $\mathbf A \mathbf x = \mathbf b$ generated from 2D Poisson equation using the standard central finite difference method, $$ \mathbf A = \begin{bmatrix} \mathbf K & -\mathbf ...
3
votes
0answers
45 views

Complex Integral Equation Solution in MATLAB

I need to solve an integral equation in the form: $$A(z)+\int\limits^{z_2}_{z_1}B(z') \frac{z^N}{z^N-z'^N} \frac{e^{i\beta}}{|z|}\mathrm{d}z'=0 $$ where $A(z)$ distribution is known and we are ...
3
votes
0answers
73 views

What is Chebfun `eigs` doing

What is this doing? Looks like the original eigenvalue problem is converted into generalized eigenvalue problems with different dimensions of collocation points. Can someone explain more about this? ...
0
votes
0answers
80 views

Couple system of PDEs using MATLAB pdepe

I would like to use Matlab's pdepe to solve this system with cubic sources: $ s_t =(sr)_x + s_{ xx }+s(s-1)(1-s) $ $ r_t =(\frac{ A }{ B }r^2+s)_x + \frac{ A }{ -K }r_{ xx } $ where A, B and ...
1
vote
0answers
72 views

Band structure of nonlinear Schrodinger equation with one dimensional potential

I have a nonlinear Schrodinger equation which reads: $$ \frac{1}{2} \frac{d^2u}{dx^2}+ |u|^2u + V(x)u = -i \frac{du}{dz},$$ where $V(x)=\cos(wx)+ i a \sin(wx)$ and $w$, $a$ are numbers. How to ...
0
votes
1answer
90 views

PDEPE nonlinear

I would like to use Matlab's pdepe to solve this system: $$ s_t =(sr)_x + s_{ xx } \\ r_t =(\frac{ A }{ B }r^2+s)_x + \frac{ A }{ -K } r_{ xx } $$ where $A$, $B$ ...
0
votes
1answer
212 views

Finite Element Analysis for Laminated Plates with Holes or Patches

As the title says, I am trying to code in FEM a plate structure that either has a hole in one of the layers or one of the layers is made of patches of plates, rather than one whole plate. However, ...
3
votes
1answer
188 views

FEM current toy problem

I am solving the Dirichlet problem $$ \begin{cases} \Delta u = 0, \\ u|_{\partial D} = f, \end{cases} $$ in a $2d$ domain $D$ using the finite element method. What I want to get is the ...
0
votes
1answer
50 views

Normalization of MATLAB HermiteH

I was wandering - what kind of normalization does Matlab use in hermiteH, its implementation of the Hermite polynomials? It is certainly not the case that they use ...
0
votes
1answer
43 views

Chebychev Polynomial derivatives at zero points and extreme points

I was looking for some help with derivatives of Chebychev polynomials at zero points. The recursive expression, $$ T_{(j+1)}(x) = 2xT_j(x) - T_{(j-1)}(x) $$ has the derivative $$ T'_{j+1}(x) = 2T_j(...
1
vote
1answer
66 views

Solving for $C$ in $Q = YCZ$ using least squares in Matlab

I am trying to solve for the matrix $C$ in $Q = YCZ$ in matlab. I have preliminary results but they don't seem realistic. Here, $Q$ is $n \times m-1$, $Y$ is $n \times p$, $C$ is $p \times m$ and $Z$ ...
0
votes
1answer
96 views

Derivatives of a Chebychev polynomial

I am using Chebychev collocation nodes for approximation, and my problem requires me to calculate derivatives of the polynomial. I have been reading from a few sources, but I am not sure I understand ...
-2
votes
1answer
144 views

Adding Non-Linear source term to 2d Implicit MATLAB code

I'm running out of time for this code so any help would be greatly appreciated. I am currently coding the 2D heat/diffusion equation in matlab but i'm having trouble adding in the source term. my ...
0
votes
1answer
191 views

Modelica and SIMULINK yield completely different results

I'm trying to simulate a 1D model of two bodies sliding on each other with a Coulomb friction in between. As I have explained here I modeled the friction as : The force required to keep two bodies ...
0
votes
1answer
220 views

Is the exponential function, e^x, very expensive to compute in Matlab and harmful to my computer?

Is the exponential function problematic and very expensive to compute in Matlab? When I write a new term for my model of ODEs that has an exponential term in it, the program almost never finishes ...
7
votes
4answers
179 views

In Matlab, how can I be consistent with units?

I am modeling some aerodynamics equations and am using meters / centimeters, kilograms, and seconds. I've heard that, "matlab doesn't know units". So, how can I make sure that it does? Just ...
3
votes
2answers
219 views

Writing a programming code directly from the mathematical formula?

For using any programming language, a mathematical formula should be written in the corresponding code. I wonder if there is any service (for any programming language, Matlab, Mathematica, Python, etc)...
3
votes
1answer
144 views

How to compute the Frobenius norm of matrices whose entries are either too large or too small?

While implementing in Matlab the Frobenius norm of a matrix $$\| A\|_{\text F} := \sqrt{ \sum_{i=1}^m \sum_{j=1}^n a_{ij}^2 },$$ a problem arises when numbers are too big or too small: If a number ...
3
votes
1answer
254 views

Numerical propagation of a density matrix using Liouville von Neumann equation

I want to look at time evolution of the density matrices of some, very simple, spin systems, but I am having trouble with my approach. I want to use a simple for-...
0
votes
1answer
32 views

Plotting using 'colorbar' in MATLAB [closed]

I am trying to plot a figure similar to the one attached here,I tried searching how to do a similar kinds of plot and i found about 'colormap','colorbar' in MATLAB. Actually I want to plot this ...
1
vote
1answer
119 views

Create mesh for complicated 3D object for finite element analysis

I see images of steel connections, concrete dams, and other complicated 3D objects in papers which finite element analysis has been performed on them. My questions are: How these objects are created ...