Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
2
votes
0answers
22 views

Find $x$ that satisfy $(I-A^*A)+x(\frac{A+A^*}{2})\prec0$ using LMI or SDP on Matlab

Given $A\in\mathbb{C}^{n\times n}$, I want to use LMI or SDP to find feasibility of $x>0$ in the following inequality: $$(I-A^*A)+x(\frac{A+A^*}{2})\prec0,$$ where $D\prec0$ means that $D$ is ...
3
votes
1answer
79 views

Type of computer used for computation

In some scientific papers I see that authors provide what type of simulation tool and what type of computer was used for computation. For example: The computations were performed using MATLAB in ...
1
vote
0answers
17 views

How can this attempt to implement a Milstein numerical approximation for an Ito process of multiple components be fixed?

I have been reading Kloeden and Platen's Numerical Solution of Stochastic Differential Equations, and have more or less been trying to systematically complete the various exercises therein as I go ...
0
votes
1answer
35 views

Best search algorithm for optimal weight factor in SOR method

I had written an algorithm that searches for the optimal weight parameter to be implemented in the successive-over relaxation (SOR) method which worked cleanly by vectorizing the interval and for ...
1
vote
1answer
95 views

2-norm and infinty norm of a system in controls

How to compute 2-norm or infinity norm of following system? i am confused whether to calculate using simple matrix theory "where it don't regard for s domain" or H2 and H-infinty norm. ...
1
vote
1answer
206 views

What is difference between L2 norm and H2 Norm?

When someone refers 2-norm of system,L2 and H2 are used interchangeably by author and is rather confusing. Even the matlab has different functions for H-infinity norm and L-infinity norm. as shown in ...
-1
votes
1answer
30 views

relres in gmres MATLAB

I think the relres in MATLABis the form that relres = norm(M(b-Ax))/norm(M\b),when it smaller than tol then stop the iteration. I want to know how to change relres to norm((b-Ax))/norm(b). Or use ...
1
vote
2answers
175 views

Continuation of solution to $-\nabla\cdot (k(x,y)\nabla u)=f$

I'm trying to solve the following problem, I had previously opened another discussion for the implementation and well, it seems that it has turned out well, it can be found here. I need to calculate ...
1
vote
0answers
43 views

Can we solve can overdetermined coupled equations in matlab?

...
2
votes
1answer
87 views

Vectorization Matlab/Octave of Markov Matrix Powers

I have just created a code snippet in Octave/Matlab that aims to create a plot which shows the accuracy of an initial probability vector $\vec{\pi}$ derived from the transition probability matrix $\...
3
votes
1answer
99 views

How can I extract the banded or block diagonal part of a sparse matrix in MATLAB?

Given a large sparse (square) matrix in MATLAB, how can I extract the banded or the block-diagonal parts (of fixed size) of it efficiently? These are useful operations when prototyping and testing ...
0
votes
1answer
44 views

Efficient solution to linear system involving Kronecker sum in MATLAB

High dimensional finite difference problems often lead to linear systems of the form $$ A x = b, \qquad A = B_1 \oplus B_2 \oplus \cdots \oplus B_d, $$ where $\oplus$ denotes the Kronecker sum. $B_i \...
1
vote
1answer
147 views

What is the use of arrayfun if a for loop is faster?

This may not be so much of a scientific computing question but more of a MATLAB question, if that is the case, please feel free to close or migrate the question. Root-finding problems are commonly ...
0
votes
2answers
340 views

Implementing routine for $-\nabla\cdot (k(x,y) \nabla u)=f$ in Matlab

I am solving the Poisson Equation for 2D given by the following expression: $$-\nabla\cdot (k(x,y) \nabla u)=f$$ in a rectangle with Dirichlet conditions on the boundary using Matlab. In principle I ...
0
votes
0answers
63 views

Path constraints for state variables - fmincon, ODE45

My problem lies in constraining state variables (look for 23,24,25). I am currently using ODE45 to solve equations and fmincon to find best control variable.How would you go about solving this? Here ...
5
votes
2answers
552 views

Specifying ode solver options to speed up compute time

I'm specifying the 'JPattern', sparsity_pattern in the ode options to speed up the compute time of my actual system. I am sharing a sample code below to show how I ...
4
votes
1answer
97 views

How are Matrices Stored in MATLAB?

I have this simple question but I am trying to figure out why: Are matrices stored column-wise in MATLAB? If so then why? I theorize that they are stored column-wise because the memory does not have ...
0
votes
0answers
53 views

Can I get a symbolic solution for these coupled ODEs?

I found this IPython notebook called ‘Roller Coaster’ from", "numfys.net, where they model the movement of a ball over a path described by a third-degree polynomial $y(x)$ with slope $\...
0
votes
1answer
44 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
175 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
36 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
33 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
92 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
42 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
48 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
85 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
26 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
90 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....
1
vote
1answer
113 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
87 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
169 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
78 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
42 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
75 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
55 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 ...
1
vote
0answers
68 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
98 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
45 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
65 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
119 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
38 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
153 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
124 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
194 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
101 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
173 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
58 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
286 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
94 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
2 3 4 5
16