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.

4
votes
0answers
38 views

Numerical stability of higher order Zernike polynomials

I'm trying to calculate higher order (e.g., m=0, n=46) Zernike moments for some image. However, I'm running into a problem ...
0
votes
0answers
22 views

Generalization of a matrix known for some values [on hold]

Preliminaries: and  I wrote Maple code for above. Download the Maple code for Above:   Now, we can calculate the Matrix    as follows  for $k=2, M=3$, Question:  How can we write (Maple or ...
-1
votes
0answers
33 views

How to create a 3D random complex array with conjugate symmetry in matlab or other languages

For a 3D array A to be conjugate symmetry, then A = conj(A([1 nx:-1:2],[1 ny:-1:2], [1 nz:-1:2])) for A having size nx,ny,nz. I will be so happy if I get help on this.
-1
votes
0answers
26 views

Non linear system using Gauss Newton

I'm trying to solve this question whose growth function is given as: Pk = (r^k) * P0 Where pk = [0.19 0.36 0.69 1.3 2.5 4.7 8.5 14] k = [1 2 3 4 5 6 7 8] The unknowns I'm trying to solve for is r ...
0
votes
0answers
38 views

System of BVPs with unbalanced BCs

I have a system of ODEs forming a BVP. I was thinking of using Finite Difference to solve it but for some functions I do not have the BCs on both sides (though in total they are enough to make the ...
-1
votes
0answers
43 views

Solving a system of ODEs and one PDE with bvp4c

knowing that bvp4c is based on Finite Differences, would it be possible to solve a system of ODEs with also a time and space dependent parameter? Thank you.
-1
votes
0answers
42 views

Implementing Danckwert’s boundary condition for the PDE

This is a follow-up to my previous question posted here. I was suggested to use the pdepe function in MATLAB to solve the PDE, $ \frac{\partial C}{\partial t} = -v\...
-1
votes
0answers
21 views

Finite difference Problem Boundary Value Problem in Matlab

I am trying to solve boundary value problem using matlab.I have implemented algorithm from Numerical Analysis-Richard L. Burden book. But it is very difficult. Is there any way to generate the ...
-1
votes
0answers
50 views

Question regarding implementation of boundary condition

I have the following code, which solves for the change in concentration of a species along the length of a channel of length L . The equation is , $ \frac{\partial C}{\partial t} = -v\frac{\partial C}...
2
votes
1answer
172 views

Step-size selection for an Trapezoidal Method ODE solver (ode23t)

I was reading the documentation of the MatLab ODE solver ode23t, and I've seen that the trapezoidal rule is used. Moreover, the error is estimated by ...
1
vote
0answers
77 views

Finite differences for the one-phase Stefan problem

I am trying to code the one-phase, one-dimensional Stefan problem using finite differences in Matlab, similarly to what has already been done in Mathematica (see https://mathematica.stackexchange.com/...
0
votes
2answers
56 views

Plot a multi-variable equation in (discontinuous) regions

The goal is to display the relation between K and E in the following equation: $$\cos(K) = 5 \text{sinc}( 5.12\sqrt{E} ) - \cos(5.12\sqrt{E} )$$ The intended result is: However, using the following ...
0
votes
1answer
28 views

How do I find the default ODE solver tolerances in Matlab?

You can set the Absolute or Relative ODE solver tolerances in Matlab with the options structure from an odeset command. But how do I find the default values for the ...
2
votes
1answer
29 views

Log-transformation of decision variables in parameter estimation

I am trying to find the diffusion coefficient ($D$) and the partition coefficient ($KLP$) using experimental data of desorption of a pollutant from a film into a liquid. This process can be modelled, ...
3
votes
1answer
187 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 ...
1
vote
1answer
79 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
140 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
100 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
3answers
194 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{...
6
votes
2answers
297 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
69 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
1answer
88 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
51 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
54 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
96 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
53 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
58 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
73 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
1answer
128 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 ...
4
votes
1answer
55 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 ...
1
vote
1answer
72 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
91 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
63 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
138 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
147 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
108 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
65 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
387 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
51 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
51 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 ...
4
votes
0answers
57 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
77 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
123 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
79 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
111 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
310 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
192 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
52 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
45 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
67 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$ ...