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.

3
votes
2answers
216 views

Given x,y,z data of a periodic object, calculate the period of the object (if possible)

So the problem I am working on is as such. Given the x,y,z data of a periodic object over time (from the origin in 3d space) (need not be uniform), calculate the period of the object (if the data ...
1
vote
0answers
131 views

Spectrum of the Laplace operator

I am studying the discretization of Poisson's equation in $1D$. In Matlab I created different discretization matrices (Laplace operator) according to different sizes of the mesh: ...
1
vote
0answers
63 views

Is MATLAB feasible for app deployment versus lower level languages [duplicate]

MATLAB/Octave is a pretty useful language for prototyping scientific computation use cases, however I would like to know if the sheer nature of being a high level language bottlenecks how fast the ...
1
vote
0answers
273 views

Inputting a time dependent function into ODE45 [closed]

I am currently trying to model random waves on a buoy system. I am running into the issue of implementing a random wave function. ...
4
votes
4answers
917 views

Practical coding resources for new CFD practicioners

There seem to be many books and papers that explain various CFD methods in great detail, but unfortunately I have not been able to find many good resources of such methods implemented in codes such as ...
1
vote
0answers
121 views

How to implement chaotic sender and receiver with ordinary differential equations?

I am referring this paper, and trying to implement chaotic sender and receiver, to decode message, as given in section $V^{th}$ Chaotic signal masking. The process that I want to implement is figure ...
2
votes
1answer
149 views

Any FOSS MATLAB/Octave toolbox for high-speed variable precision arithmetic?

I need to use variable precision arithmetic in MATLAB for an expensive set of computation. The vpa function provided by the symbolic math toolbox is very slow. I found a non-free alternative toolbox ...
1
vote
2answers
38 views

Optimisation of purely integer quantity with bound-constraints for a 1D expensive function whose analytical form is not available

I have a computationally expensive objective function, whose analytical form is not available. The only input argument to the objective function is an integer variable. The goal is to compute the ...
0
votes
1answer
125 views

How to Apply a Uniform Load to a Laminate Plate in FEM

As the title says, I'm trying to make my code include a uniform pressure/force to the surface of a plate for analysis. Structural/Element Modeling I am modeling a 2D 9 node Mindlin plate that has a ...
0
votes
1answer
97 views

Obtaining extra output argument(s) from the objective function used by fsolve in MATLAB

I have a MATLAB code (see below) that employs 'fsolve' from the optimization toolbox for a root finding problem. The bottleneck is that, within the objective function calculation, there is a ...
2
votes
3answers
582 views

How to get multiple solutions for a optimization problem using any kind of software

I have a optimization problem in which the optimal objective value occurs at multiple point in the feasible space. If I run my problem in LINGO software then it gives me the optimal objective value at ...
1
vote
1answer
598 views

Edge and Nodal finite element methods in MATLAB for Magnetic induction tomography

What is the difference between edge finite elements and nodal finite elements? This for use in modeling the eddy current problem in classical electromagnetism. I am attempting to convert MATLAB code ...
0
votes
1answer
110 views

Error Reduction algorithm for single measurement intensity [closed]

I'm trying to solve the phase problem from single intensity measurement. I implemented error reduction algorithm in Matlab for ...
1
vote
1answer
232 views

matlab lsqcurvefit parameter estimation journey

The lsqcurvefit solution in matlab converges at different solutions depending upon the initial guess: Surface represents the error (SSE) between model and data at various combinations of parameters ...
1
vote
2answers
2k views

BLAS libraries for Octave or Matlab, preferrably with GPU support?

I just searched around a bit for BLAS implementations and was amazed by the sheer amount of libraries around. Does someone know of a benchmark or otherwise rating of the various libraries? How easy ...
1
vote
0answers
96 views

Numerically compute PDF given a function

Consider $[0,1]$ with the Lebesgue measure $m$ and $f:[0,1]\to \mathbb{R}$, and $x$ a uniformly distributed random variable in $[0,1]$. Then, $f(x)$ itself define a new random variable. We can then ...
1
vote
1answer
190 views

Matlab symbolic differentiation of Legendre polynomials

Consider $f(x)= \sum\limits_{n=0}^N a_n p_n (x)$, where $p_n$ are the Legendre polynomials. If one wants to differentiate $f'$ symbolically, i.e. to compute $$f'(x) = \sum\limits_{n=0}^{N-1} b_n p_n (...
0
votes
1answer
48 views

Passing in a vector from this particular matrix class floating around online [closed]

I am using this matrix class here to assist me in converting this Least Squares algorithm that prices American options that is written in Matlab in C++. My question is pretty simple. I want to pass in ...
2
votes
1answer
140 views

Chattering effect using ode23s — SDOF with variable spring and periodic input force

I am attempting to model the following SDOF system with a variable spring and having a sinusoidal input, $$m\ddot{x}+(k_0+k_1)x = m(2\pi f)^2\sin(2\pi ft)$$ where $m$ is the mass, $k_0$ the original ...
1
vote
1answer
169 views

Efficiently generate a random subgraph (Gs) with maximum degree K, using only edges from an existing graph G

I am looking find a way of efficiently generating a random, undirected subgraph $G_s$ with $N$ vertices, using a subset of edges from an exisiting undirected graph $G$, also of size $N$, where the ...
4
votes
1answer
171 views

How to reformulate a 1/x^2 singular term to 1/x so that bvp4c can solve it?

I have a ''cosmetic'' problem with a singular term in my Matlab script. I am trying to solve the following system of differential equations: $$ \begin{aligned} y_1' &= y_2,\\ y_2' &= \frac{...
1
vote
1answer
143 views

How to complete sparse matrix?

I am trying to solve an equation by a meshfree method. Shape functions (and their derivatives) have a compact support domain. So, over a given integration cell used for numerical integration, only a ...
1
vote
1answer
730 views

Solving poisson equation on image with neumann boundary condition

I am trying to solve a standard Poisson equation on image with Neumann boundary condition. The Poisson equation has the form: $Δp=b$ where $b$ is the divergence of the input image,which is as shown: ...
1
vote
0answers
2k views

Split step method applied on nonlinear Schrodinger equation does not result in self focusing

I'm trying to simulate self focusing in the case of anomalous dispersion and positive Kerr nonlinearity in the nonlinear Schrödinger equation $\frac{\partial a}{\partial t} - i\frac{\partial^2 a}{\...
0
votes
1answer
140 views

Iterative methods to solve linear system in 3D FEM

I implemented a FEM solver in MATLAB for Poisson's equation in 3D, using hexahedron and sparse matrix for the Laplacian. I was using the backslash but now I have to use a few iterative methods (GMRES ...
1
vote
1answer
2k views

What is “tolerance” in ODE45 in Matlab?

I have used ode45 in Matlab. And, it is my understanding that the 4 and the 5 are for the order of the global and local error, respectively. So, the global error ...
0
votes
1answer
126 views

ODE in Matlab: how to plot result and piecewise function [closed]

I have solved a second order differential equation $\ddot R=f(t,R,\dot R)$ with a piecewise function $$P(t)=\begin{cases} P_0 & \text{ if } 0<t\leq40\times10^{-6} \\ \frac{(P_0+P_{min})}{2}+\...
1
vote
0answers
140 views

How to implement the timestepping in TR-BDF2 using matlab ode solver as end-points (upper bound)?

Even though i know that i cannot advance the solver ode23tb, which uses TR-BDF2 itself, in just one timestep, i want to set an upper bound on the integration period after which I do something to ...
0
votes
1answer
1k views

FEM Stiffness Matrix is always close to Singular or Badly Scaled

I am making a code for an 18-node (3x3x2) 3D element FEM. However, even though I am (pretty) sure that all the shape functions are correct and whatnot, whenever I try and invert the stiffness matrix ...
1
vote
0answers
59 views

Convert scipy integration with one step to matlab integration

Scipy integration allows us to do ode integration one adaptive timestep at a time and do something to it. However, matlab ode needs us to specify a timespan , and determine the adaptive timestep ...
3
votes
1answer
300 views

ODE45: doubts about the result. Correct or not?

I have to solve $$\left\{\begin{matrix} x\ddot{x}+\frac{3}{2}\dot{x}^2=\frac{1}{\rho}\left (P_v-a_1t^2-a_2t-P_0 \right )\\ x(0)=5\cdot10^{-6}\\ \dot{x}(0)=0 \end{matrix}\right.$$ I do not know if ...
0
votes
1answer
80 views

MATLAB: Matrix whose elements depend on its indicies

I am trying to put the function $$ f(\mu,\nu) = i^{\nu-\mu} \sum_{0}^{19} H_{\mu-\nu}(7j) + \delta_{\mu,\nu}\ ,$$ $\mu, \nu =-3,-2,...2,3$ into a 7x7 matrix, where $H$ is the Hankel function of the ...
1
vote
1answer
1k views

3D Solid 8 Node FEM Matlab Code

So this semester, I'm taking a Finite Element Method course at my graduate school. We started out making codes for 1D bars and came all the way to 8 node solid elements. However, I seem to have run ...
-1
votes
1answer
122 views

ODE15s: unable to meet integration tolerances

I have to solve $$\left\{\begin{matrix} \ddot{R}=-\frac{3}{2}\frac{\dot{R}^{2}}{R}+\frac{1}{R\rho}\left [P_{v}(T_{\infty})-P_{0}-a_{1}t^{2}-a_{2}t+\frac{(L\rho_{g})^{2}}{hT_{\infty}}\dot{R}-4\mu \frac{...
1
vote
0answers
101 views

MATLAB ODE15s: imaginary parts

I have to solve $$\left\{\begin{matrix} \ddot{R}=-\frac{3}{2}\frac{\dot{R}^{2}}{R}+\frac{1}{R\rho}\left [P_{v}(T_{\infty})-P_{0}+\frac{(L\rho_{g})^{2}}{hT_{\infty}}\dot{R}-4\mu \frac{\dot{R}}{R}-\frac{...
2
votes
1answer
148 views

Contour plot of a scalar function over the complex domain in MATLAB

I'm trying to make a 2D contour plot of a function with a complex input and a real output, namely: $f(z=x+iy)= |z^2-3z|$, on MATLAB. I want to make a contour plot of f, such that the axes are $(x,y)$, ...
1
vote
1answer
100 views

Numerically Approximate $[n\cdot\nabla u_h],$ without using Matlab function

Suppose that $\Omega\subset\mathbb{R}^2$ and we define the triangulation $\mathcal{T}_h$ where, $$\mathcal{T}_h=\bigcup_{i=1}^nK_i$$, with $K_i$ are triangles. We have the explicit a posteriori ...
0
votes
3answers
525 views

Matrix of linear transformation in MATLAB

How can I determine a matrix $R$ in matlab such that, given a known matrix of coefficients $A$ gives me back its row reduced echelon form? Obviously I need an algorithm/function that works also with ...
0
votes
2answers
198 views

Matlab: ode45 loop

I have to solve this equation $$\ddot{x}x = -\frac{3}{2}\dot{x}^2 + \frac{\dot{x}}{h} + \sin(t)$$ where $h$ is defined by $$h = \left(\frac{\dot{x}}{h}\right)^{1/3} + \frac{\dot{x}}{h}$$ My idea ...
0
votes
2answers
130 views

Integrate result of finite element calculation in MATLAB

I have a PDE that I solve in MATLAB over a 2D domain using the "recommended workflow", i.e. the functions descg, ...
-1
votes
1answer
240 views

Which ODE solver in Matlab allows me to advance in just one timestep only

[t,y] = odeXX(odefun,tspan,y0) I have a solver odeXX, and the tspan = [0 0.0001]. It seems that for any ode solver in MATLAB, they integrate by breaking ...
0
votes
1answer
123 views

Optimization with Yalmip [closed]

I would like to solve in Matlab the following optimization problem $$\begin{array}{ll} \text{maximize} & \bigg\| \displaystyle\sum_{l=1}^{2}\alpha_l \int_{\tau_{m+l-1}}^{\alpha_1\tau_m+\alpha_2\...
1
vote
2answers
236 views

Solving PDE in 1D with FD and MATLAB

I have to solve the following equation: $-u_{xx}=1$, with $x\in(0,1)$ and $u(0)=0,u(1)=0$. I have to solve it with the following numerical scheme: $\frac{1}{h_k^2}(-\frac{1}{2}u_{k-1}+u_k-\frac{1}{...
6
votes
3answers
705 views

Efficiently computing the product of a multi-dimensional matrix (or tensor) and vectors

Update: Thank you very much for all of you who answered below. I'm studying each answer now. In the long term, I'm more interested in solutions that work for sparse tensors (sorry I should have ...
1
vote
1answer
5k views

Implementation of the Jacobi iteration to find the solution to $Ax = b$

I implemented the Jacobi iteration using Matlab based on this paper, and the code is as follows: ...
1
vote
0answers
35 views

Solving HJ using Hopf-Lax formula (Burgers case)

Hi I want to approximate $u(x,t)$ solution of: $\begin{cases}u_t+H(u_x)=0 \\u(x,0)=u_0(x)= e^{−(x−3)^2} \end{cases}$, where $H(u_x)=\frac{u_x^2}{2}$ and my spatial domain is $\Omega=[0;10]$. Now i ...
1
vote
2answers
393 views

Find a permutation matrix (using the Matlab's function $symrcm$) of a matrix $A(2:end, 2:end)$

I've the following Matlab code: r = symrcm(A(2:end, 2:end)); prcm = [1 r + 1]; spy(A(prcm, prcm)); where A should be sparse ...
1
vote
1answer
263 views

Pool two computers for MATLAB parfor without MDCS

I have two identical computers, both with 4 dual cores and MATLAB installed on them. They are connected to the same network. Is there anyway I can run a parforloop using the computation power of both ...
3
votes
2answers
337 views

PageRank using Inverse Iteration Method by Cleve Moler

I was trying to understand how to use the inverse interation method to compute the page rank as an exercise. In this chapter (page 4) about page rank (by Cleve Moler), the author suggests to use the ...
0
votes
1answer
66 views

Difference Equation PDE in MatLab

I would like to program the following difference equation. Find numbers $v_{i,j}$ so that for $1\leq i\leq 4$, $0\leq j\leq 5$: $$ v_{i,j+1} = (0.1)v_{i+1,j} + (0.8)v_{i,j} + (0.1)v_{i-1,j} $$ In ...