Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
-1
votes
0answers
45 views

A boundary value problem - an example [closed]

The matlab code below can solve finite difference method of any boundary value problem. But I am facing some challenges editing the code to suite my taste. For example in the code, you have to create ...
0
votes
1answer
38 views

Round-off error step choice

In the Numerical Recipes in section 5.7.- Numerical derivatives the choice of the step size $h$ in the numerical derivative should lead to a difference between $x$ and $x+h$ representable by an exact ...
1
vote
1answer
117 views

MATLAB : find an algorithm to inverse quickly a large matrix of symbolic variables

I have to solve the equality between 2 matrixes 12x12 containing a lot of symbolic variables and with which I perform inversion of matrix. There is only one unknown called "...
0
votes
0answers
34 views

Using event function to shift between 2 sets of ODE

I have a bunch of ODEs I am trying to solve using ode45 in MATLAB. I have hidden the details of the equations to keep it simple (so as to build a general algorithm)! \[\frac{dR}{dt}= F_{1}(R,N) \quad\...
2
votes
0answers
26 views

Problem with Numerical DAE Implementation of Nernst-Planck Equations

I write to you all today in order to clarify if I implemented my model correctly into MATLAB. I will outline the following: analytical governing equations, my discretization for the equations and ...
0
votes
0answers
72 views

Error $L_{2}$ convergence in Finite Element for Poisson Equation

I have written a Matlab code to solve the equation $-u'' = f$ with conditions $u(0) = u'(1) = 0$ on the domain $x \in [0,1]$. I tested the code with $f(x) = -2, \forall x\in [0,1]$. I check the plot ...
0
votes
1answer
34 views

Rem function in Octave showing wrong result

I am trying to write an if statement that checks if 2 numbers are divisible before running some commands. The problem is, the rem function is giving some wrong results for certain number (2 is ...
-1
votes
1answer
45 views

How to reduce computational time in DDE simulation on Matlab

I need to simulate a network of nodes. The weights of the edges are being given in a matrix . Due to the non-zero distances between the nodes, we consider time-delays, which are computed given the ...
1
vote
0answers
76 views

Advection equation boundary conditions in 2D unstructured grid

Currently struggling with boundary conditions for 2d advection equation. left dirichlet u = (1,0) bot top dirichlet u = (0,0) right neumann du/dx = (0,0) ...
0
votes
1answer
23 views

Software to find zero divisors of a ring

Are there some programs with packages that help to list all zero-divisors of the ring we desired? especially for the ring of Gaussian integers modulo $n$, $\mathbb{z}_n[i]$. Also want to find which of ...
-1
votes
1answer
59 views

ODE45 and a variable that assumes multiple values during the timespan

I have tried in different ways to see what happens to voltage V and gating conductances m, n and h when, at time step x, current I switched from 0 to 0.1, and then at time step x + n it gets back to 0....
0
votes
1answer
72 views

Reason behind different outputs for Fast Fourier Transform in Numpy and Matlab

Here is the output of Numpy np.fft.ifft([0, 4, 0, 0]) array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j]) # may vary Here is the output of Matlab ...
0
votes
1answer
76 views

Visualize a mesh from list of 3D point and faces

I have a list of vertices and faces. Now, I want to create a mesh using the given points and faces list and visualize it. Also, I want to play with the mesh by adding an extra point on the faces. Can ...
1
vote
2answers
159 views

How can I learn Scientific Python?

I am an intermediate user of Matlab and Mathematica, but I would really love to start learning Python language for scientific purposes (I am interested in Maths and Physics). Could please someone ...
1
vote
0answers
72 views

C.S.R method in finite element matrix assembly

I have solved the 2D Poisson equation using finite element method with simplex triangular element in MATLAB. First, I generated the triangular mesh using pdetool in ...
-2
votes
1answer
39 views

Solving differential equation by setting vectorization `on` in MATLAB

This is a follow up to my previous question posted here. I've set up an ode system in MATLAB and I'm trying to vectorize the code to increase the speed of computation. The follow is the code for my ...
0
votes
1answer
55 views

Solving differential equation by specifying jacobian pattern

This is a follow up to my previous question posted here I'm trying to construct the sparsity pattern of the jacobian matrix to speed up the computation of a large system of odes. The following is the ...
1
vote
1answer
46 views

solving differential equations with jacobian pattern

I'm trying to compare the simulation time for solving a system of differential equations with and without jacobian pattern for a toy model using ode15s in MATLAB. ...
2
votes
0answers
42 views

How to solve this boundary value problem which has more unknown than equation on MATLAB

I need your helps about solving the problem below with MATLAB. I am trying to solve 2D Stress Wave Propagation problem by using FDTD(Finite difference time domain) method on the cylindrical coord. I ...
0
votes
0answers
19 views

Improve code of logarithmic quantizer

I am implementing a logarithmic quantizer which is defined as follows: $$ q(u) = \begin{cases} u_i , \frac{u_i}{1+\delta} < u < \frac{u_i}{1-\delta} \\ 0 , 0 \leq u \leq \frac{u_o}{1+\delta} \\ -...
3
votes
1answer
94 views

Anomaly in 2-body simulation error

I've generated a solution for a planet motion around the Sun (placed at the reference frame center). I wanted to test what would I get for the error of the method I'm using (Runge Kutta with 4 stages, ...
0
votes
0answers
28 views

Calling User defined Matlab Functions in Python with Matlab.engine API

I am trying to combine Matlab and python scripts and figure out if I can achieve a better solution in terms of the solver-runtime. A very simple optimization problem is used just for now. But I got in ...
0
votes
1answer
59 views

How to solve a Stiffness matrix?

I am quite new in this field. For my university I prepared a stiffness matrix to solve for a project group. This matrix consists of 450 equations with 450 unknows (it's a Matlab script) and I have the ...
0
votes
1answer
94 views

Verification of order of convergence of Implicit Euler Method to numerically solve Black-Scholes PDE

I'm trying to verify the order of convergence for implicit Euler method to numerically solve Black-Scholes PDE. Theory says that it should be $O(\Delta t + \Delta S^2).$ My code is working absolutely ...
0
votes
0answers
30 views

Estimating the Jacobian in Harmonic Balance Method

I am trying to solve a set of ODEs using the Harmonic Balance method. In order to do this, I need to compute the Jacobian of the set of equations. However I am very confused regarding the dimensions ...
0
votes
0answers
80 views

“This DAE appears to be of index greater than 1” daeic12 (line76) error code

Hi I am trying to solve a set of pde converted into ODE and DAE using central finite difference method. I have used the MATLAB 'solve' command to determine the coefficients of fictitious nodes for ...
5
votes
2answers
121 views

Exponent log to compute reciprocal power?

A MATLAB library seems to overcomplicate a computation: exp( (log(a) - log(b))/b ) which is mathematically equivalent (assuming real & positive ...
2
votes
2answers
187 views

Matlab - Compute approximative common eigenvectors basis between two matrices as a function of tolerance

I am looking for finding or rather building common eigenvectors matrix X between 2 matrices A and B such as : ...
0
votes
1answer
100 views

Numerical solution of ill-conditioned differential equation

I want to solve the following Cauchy problem \begin{equation} y' = y^2 + \frac{t^4 - 6t^3 + 12t^2 - 14t + 9}{(1+t)^2} \end{equation} with initial condition: $y(0) = 2$ for $t \in [0,1.6]$ using a 3 ...
0
votes
0answers
129 views

Problem with solving coupled ODE and DAE equations with mass matrix (Error using daeic12 (line 77) This DAE appears to be of index greater than 1)

I am trying to solve 6 ODE equations coupled with 1 DAE one. The ODE equations have been discritized in space domain and ode15s MATLAB solver is used to solve the equations in time domain. I have ...
0
votes
1answer
57 views

(2) Trying to model a simple second order ODE: Why time-step smaller is not better

This question is related with this other question: Trying to model a simple second order ODE. On this other question, I get some useful comments on why the simulations are so terrible. However, I have ...
4
votes
2answers
279 views

Trying to model a simple second order ODE

I am studying some computational methods and I am trying to program simples equations to understand how the methods work... Particularly, I am trying to understand how multiorders ODE's work. I've ...
0
votes
1answer
75 views

What are the advantages and disadvantages of using norm error control in the MATLAB ODE suit?

In MATLAB's ODE suit, there seem to be two basic methods of controlling the Local Truncation Error (LTE) of the ODE which the user can choose from, namely: The absolute error control (default), ...
1
vote
0answers
30 views

What's the best way to implement a least-squares estimation of a motor system in MATLAB?

Basically, I'm trying to use Least-Squares to estimate the parameters of a DC motor. My system can be modeled by the following matrix equation: $$\begin{bmatrix}V_{input}(t)\\0\end{bmatrix}=\begin{...
-1
votes
1answer
85 views

Converting for loop from matlab to python

I am converting some MATLAB code in to python and have the encountered the error "ValueError Traceback (most recent call last) in 1 for ig in range(nbas): ---->...
1
vote
1answer
64 views

2-DOF Robotic Manipulator Trajectory Tracking Simulation

I am trying to simulate a 2-DOF planar robotic manipulator (have its joints follow a predefined trajectory) that's described by its dynamic model: $$ M(q)\ddot{q}+C(q,\dot{q})\dot{q}+G(q) = \tau $$ ...
2
votes
0answers
36 views

How to curve-fit the lower envelope of random sequence?

I'm more or less familiar with procedures and methods to fit a curve to experimental data, and I have done this many times using Matlab. However this time I have a problem that I'm not sure how to ...
1
vote
2answers
327 views

How to set up the differential equation system to speed up computation?

I've set up a system of differential equations, obtained after discretizing pde, in the following way ...
3
votes
1answer
74 views

Anonymous function in MATLAB

I want to write the following anonymous function in MATLAB. I have a piecewise function. I want to turn this into a single expression. How can this be accomplished in MATLAB ? $$f(x,t) = \begin{cases}...
2
votes
0answers
72 views

If dot product is commutative, why does MATLAB give different answers?

Why does the dot() function in MATLAB return different expressions based on the order in which I pass vectors?
1
vote
1answer
51 views

How I can derive the Neuman boundary condition of this system of hyperbolic equations in 1D?

I would like to research the Neuman boundary that can verify the following problem $\begin{aligned} &\text { (} P \text { )}\left\{\begin{array}{l} \frac{\partial U}{\partial t}(x, t)+A \frac{\...
0
votes
0answers
19 views

3d surface image for given datasets

I have some data that looks like as follows x-cor y-cor z-cor 0.02 0.0251 0.02 0.01 0.0257 0.02 0.014 0.02 0.03 0.023 0.003 0.05 0.013 0.002 0.77 .................... .................... ...
2
votes
1answer
83 views

Rank of a double-precision augmented matrix

Let $A$ be a matrix with real entries, and let $A_+$ be $A$ augmented by a single column. From linear algebra we know \begin{equation} \operatorname{rank}(A_+) = \operatorname{rank}(A) \hspace{10pt} ...
3
votes
0answers
75 views

Numerical Issues with DDE from SEIRU$\delta$ model

I'm new in this community. I moved this question from Math community. I'm reading the following article Article Here and my target is to replicate the results for a project. SEIRU Model: I obtained ...
1
vote
2answers
91 views

Coding up a toy model for gradient-descent — what step size to choose?

I'm coding up a simple model for gradient-descent, and using it to minimize some simple, deterministic functions. What step size could I choose that's simple enough for me to get started with? Should ...
1
vote
1answer
76 views

If analytically, a function is not differentiable at a point, does it make sense to write a finite difference code for the function at that point?

What would happen if I wrote a finite-difference code evaluated at a point where the function isn't differentiable analytically? I'm trying to think analytically vs numerically. Thanks,
0
votes
1answer
84 views

Coding up Newton's method for a mapping from R^2 to R — the Jacobian wouldn't be invertible

I'm trying to code up in Matlab a multivariable Newton's method, for a mapping from R^2 to R, but the Jacobian would be a 2x1 matrix, not square, so it wouldn't be invertible. Does this mean that ...
0
votes
0answers
32 views

How to describe function convergence and function tolerance for numerical root-finding?

I'm currently doing some practice problems on root-finding and am writing up some notes / comments on my code. In my solver code, if my function value is below the tolerance that I've set, should I ...
1
vote
0answers
71 views

How can I practice multivariable root-finding?

Recently, I've been reading up on various root-finding / optimization algorithms such as the Levenberg-Marquardt method, Gauss-Newton, Conjugate Gradient, trust-region and trust-region-dogleg. I've ...
2
votes
2answers
61 views

In a dynamical system, what might be a good reason why periodicity in an object's velocities is important?

I'm studying periodic motions in a dynamical system and, as a newbie, I narrowly think of an object's periodicity in its spatial x-y coordinates, but what might be a good reason why the existence of ...

1
2 3 4 5
15