Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
4
votes
1answer
70 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
44 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 $\...
-1
votes
0answers
46 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 ...
1
vote
1answer
121 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
1answer
40 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
137 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 ...
1
vote
1answer
180 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 ...
2
votes
1answer
251 views

Minimal surface finite differences problem - Matlab assemble

I face to the following problem: $$(1+u_x^2)u_{yy} - 2u_xu_yu_{xy} + (1+u_y^2)u_{xx}=0.$$ Problem needs to be discretized and assembled. Does anybody know how to proceed in Matlab?
3
votes
1answer
2k views

2D cross section from 3D surface

I am trying to apply the "restoring force surface" method to a dynamic linear system. The idea behind this method is that, knowing acceleration, displacement, velocity and input force it is possible ...
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
27 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 ...
6
votes
2answers
760 views

Complex Eigenvalues using eig (Matlab)

I wanted to find and plot the eigenvalues of large matrices (around1000x1000). But discovered when using the eig function in matlab, it gives complex eigenvalues when it shouldn't. For example, in the ...
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 ...
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 ...
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 ...
-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) ...
-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
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 ...
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
110 views

Plotting the difference between an exponential and its Taylor expansion as a function of number of terms?

I'm terribly green, please forgive me. I need to plot the difference between a chosen calculated Taylor expansion $e^x=1+x+\frac {x^2}{2!}+\frac {x^3}{3!}+\frac {x^4}{4!}+\frac {x^5}{5!}$... and the ...
2
votes
2answers
1k views

Solving DAE with higher index

I want to solve 7 coupled differential equations in MATLAB. I used the method of lines (MOL) to convert them to a system of DAEs. I then attempted to solve this system using ode15s. Unfortunately an ...
3
votes
4answers
288 views

How does gmres method iteration behave for this non-diagonalizable matrix?

Recently, I have been studied my lessons about gmres iteration, probably the most popular iteration method for general large sparse linear system of equations Ax=b. And the convergence is obtained ...
8
votes
1answer
9k views

Matlab solution for implicit finite difference heat equation with kinetic reactions

I am trying to model heat conduction within a wood cylinder using implicit finite difference methods. The general heat equation that I'm using for cylindrical and spherical shapes is: Where p is the ...
0
votes
1answer
77 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
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 ...
1
vote
2answers
329 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 ...
0
votes
1answer
56 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 ...
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
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} \\ -...
0
votes
1answer
95 views

Interpreting multivariable root-finding results from Matlab's fsolve algorithm

Edit: So I was able to get the same value of r that's given, when coding up the sum of squares of function values directly in the script file, rather than on the Command Window. So, maybe there's a ...
0
votes
0answers
30 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
96 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 ...
2
votes
2answers
188 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 : ...
5
votes
2answers
122 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 ...
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 ...
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
132 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 ...
4
votes
1answer
2k views

Switch between 2 equations to be given to ODE using events

I am trying to simulate a system with bilinear stiffness described by the following equations: $25\ddot{x}+15\dot{x}+330000x = p(t)$ if $x < 0.00072$ $25\ddot{x}+15\dot{x}+930000x = p(t)$ if $x &...
0
votes
1answer
76 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
88 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
2 3 4 5
16