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.

0
votes
0answers
19 views

Cannot obtain numerical solution to integral in Matlab

I have been trying to get Matlab to solve the following integral for a while (just to be clear when I say "solve" I mean "spit out a number"): ...
0
votes
0answers
56 views

Vieta’s exact solution for the three roots of the general cubic polynomial [closed]

I need help writing a code in Matlab to solve cubic equations using Vieta's... Very new to programming, so this is what I have so far: By means of a translation and rescaling, the general cubic can ...
0
votes
0answers
26 views

How to load several arrays from .txt and plot points with specifications?

I need to load data from a .txt file (<3KB) in Matlab. The structure of the data is as follows: s_0.4 2.00869311294470 1.90140098201689 4.00117387799144 2.73028990891229 ... ...
0
votes
0answers
48 views

Wrapped BVP with an unknown boundary for fluid modeling

I have a model about a fluid being extruded on a moving bed as in the 3D printing process. The model is a boundary-value problem where the right boundary is the point where the fluid attaches to the ...
0
votes
2answers
51 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
26 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 ...
0
votes
0answers
25 views

Matlab: Store parameters after looping MS_Regress_Fit

I have 25 portfolios and I use each of them in the MS_Regress_Fit package. After running each function, I need to store specific parameters. In the case of one portfolio the code is: ...
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, ...
0
votes
0answers
14 views

Error while running MS_Regress_Fit in Matlab

I very new to Matlab and I'm facing an issue while running MS_regress_fit. In particular, I need to add an independent variable to one of the equations, but I get ...
0
votes
0answers
32 views

On and off boundary condition

Hi I want to solve this problem using ode15s solver. Only issue I am not getting that is; this problem has a on and off boundary condition for specific time each day. To make it more specific say ...
3
votes
1answer
114 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
64 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
66 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
2answers
171 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
229 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
67 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
73 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
50 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
48 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
91 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
43 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
43 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
55 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
107 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
84 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 ...
4
votes
1answer
53 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
43 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
86 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
59 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
136 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
135 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
78 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
304 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
50 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
55 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
74 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
108 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
76 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
95 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
247 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
189 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
100 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
161 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 ...