Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
1
vote
1answer
62 views

Calculating a limit as parameter goes to infinity

I have a fair background in pure mathematics and right now my project is a numerical implementation of a certain algorithm. I have some numerical background, but not all that much, so the question is ...
1
vote
0answers
563 views

How accurate is cumtrapz in MatLab?

Say I have a set of discrete acceleration data and want to integrate it to get a set of velocity data. How accurate is the cumtrapz (Cumulative trapezoidal ...
0
votes
1answer
2k views

Multiplying two functions in MATLAB

I want the product of two functions $f(x),g(x)$ $$f(x) = x + \sin(x)\\ g(x) = x - \sin(x)$$ then $$f(x)g(x) = x^2 - \sin^{2}(x)$$ How could I compute the product of two functions?. I tried ...
8
votes
0answers
628 views

Numerical implementation of the Dirichlet-to-Neumann map

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 ...
1
vote
1answer
375 views

3D visualization in MATLAB

I have a function of 3 variables like $V= f(r_1, p, r_2)$, I want to plot these 4 data in one graph to be able to capture the behavior of V with respect to all three variables. I searched a little ...
1
vote
1answer
218 views

Solid volume calculation

In order to calculate the volume of the solid defined by $$\frac{51}{100} (\cos x \cos y+\cos x \cos z+\cos y \cos z)+\cos x+\cos y+\cos z+1\le0$$ where $x,y,z\in[0,2\pi]$ I used the following code ...
1
vote
2answers
318 views

Assemble P2 finite elements - Matlab or references

I would like to implement P2 (or even P3...) finite elements in Matlab. I need to be able to control the construction of the rigidity and mass matrices ($ \int \nabla \varphi_i\cdot \nabla \varphi_j$ ...
1
vote
3answers
476 views

2D simulation of a particle with different diffusion coefficient in different directions of the particle

How can one simulate diffusion of a particle which has a natural axis and diffusion coefficient of the particle in the direction of the axis is D_1 and in perpendicular to the axis is D_2? Could ...
0
votes
1answer
66 views

Matlab struct vector

(I resume my question with a simple example) I want to create a struct in matlab/octave as follows c(1).x = [0 1]; c(2).x = [0 1]; ... c(100).x = [0 1]; ...
1
vote
1answer
618 views

Plot 2D piecewise constant in matlab in a finite elements mesh

I need to generate a discontinuous plot (piecewise in each triangle) in matlab, something like: This plot is from http://www.alecjacobson.com/weblog/?p=3616, but I don't understand how generate it. ...
1
vote
0answers
98 views

Composite Laminate Mass Matrix Help

So, as the title of the post implies, I'm making an FEM code for a composite laminate plate using the Mindlin plate theory. And, as I am trying to get the mode shapes for the plate, I needed to make a ...
3
votes
1answer
608 views

Position Estimation using 2D multilateration for non-intersecting distances

I am trying to estimate the position of a point $P$ in Matlab. I have $n$ access points (AP) at known positions ($n>2$) as well as the distances to the point $P$ from each AP. These distances all ...
4
votes
1answer
3k views

How to compute the Helmholtz decomposition of 2D and 3D vector fields?

I have a sample of 100 particles with their 3D positions and velocities. I want to decompose the velocity vector field to its curl free and divergence free components. Is it a feasible to do so for ...
3
votes
0answers
389 views

MATLAB: solving multiple ODE systems in parallel

I have a system of parameterized ODEs that I would like to solve using MATLAB and its ode45 solver, and was wondering if it is possible to perform such a task in ...
0
votes
1answer
793 views

How to implement an integral condition when solving a BVP in MatLab

I am trying to solve a coupled system of ODE's using MATLAB's bvp4c function. I want to impose the condition that $$\int_{0}^{\pi} y_{1}(t) y_{1}(t) dt = 1,$$ where ...
1
vote
0answers
213 views

Estimate $L_2$ norm of a elliptic problem with unknown exact solution on finite element method

I have the elliptic problem $$-\Delta u = 1,\,\,\Omega\subset\mathbb{R}^2$$ with $u=0$ on $\partial\Omega,$ with $\Omega=[-1,1]^2\backslash([0,1]\times[-1,0])$ and I want to estimate the $L_2$ error ...
6
votes
6answers
5k views

What is the difference between MATLAB and FORTRAN?

In our university some Ph.D students for computational methods prefer FORTRAN over MATLAB. I can't understand why? What is the difference between them when are used in computational methods like ...
1
vote
1answer
279 views

Trouble getting steady-state solution by solving system of nonlinear algebraic equations in MATLAB

Background I have a stiff system of 6 ODEs, represented in MATLAB as follows: ...
0
votes
2answers
281 views

Random walk on lattice

I have a $9 \times 9$ square lattice. In each site of the lattice, there are $N$ molecules, where $N$ is a large random number and it is different for different sites. N equal to 100000000+-100 in ...
1
vote
0answers
141 views

Eigenvalues using QR iteration

I'm trying find the eigenvalues of a matrix A using QR iteration with Householder. I used this code which I found from Cornell University that decomposes QR with Householder. ...
2
votes
2answers
764 views

MATLAB FFT Differentiation

I am trying to implement the Laplacian operator using Fourier Transform differentiation (https://en.wikibooks.org/wiki/Parallel_Spectral_Numerical_Methods/...
3
votes
2answers
233 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
144 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
68 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 ...
4
votes
4answers
2k 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
203 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 ...
1
vote
1answer
312 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
44 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
232 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
371 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
1k 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
985 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
168 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
533 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 ...
3
votes
2answers
5k 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
110 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
310 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
58 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
192 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 ...
4
votes
1answer
278 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 ...
3
votes
1answer
377 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
226 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 ...
2
votes
1answer
1k 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: ...
0
votes
1answer
198 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
7k 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
147 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
238 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
2answers
3k 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
69 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
355 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 ...

1
4 5
6
7 8
16