Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
3
votes
3answers
2k views

Does OOP work easily and efficiently in parallel computations? [closed]

I am working on a task for which the object oriented (OO) approach fits well. I am doing it in MATLAB, since I am in the prototyping phase. However, I know that later I will surely have to perform ...
2
votes
1answer
166 views

MATLAB : Does the qr algorithm and the DGEMM used in MATLAB take into account if the input matrix is tridigonal and optimize accordingly?

Let's say we want to solve for the eigen-values of a symmetric matrix of size $n$ x $n$. In the Phase 1 of the computation, the matrix is reduced to a tridigonal form using Householder/Arnoldi's ...
5
votes
3answers
1k views

matrix storage, many rows or many columns?

tl;dr Should I store a matrix of Nx3 elements row-wise or column-wise, if I'm going to access 3 elements at a time? Does it matter? I'm setting up a numerical simulation with matrices of x,y,z ...
1
vote
2answers
2k views

Finding rate of convergence by curve fitting in Matlab

I have some data: number of nodes $N$ and error in energy norm corresponing to it. I have seen in some references that the rate of convergence is reported by $$\| u-u_h\| _E=CN^{\alpha} $$ How can ...
0
votes
2answers
137 views

Matlab Vectorization of columns in a 2D matrix and single element multiplication

MATLAB. I am trying to vectorize a loop in which each column vector of a 2D matrix (n-by-n) is found by multiplying each single element in a diagonal matrix with a column vector in another n-by-n 2D ...
2
votes
0answers
81 views

How can I use ODE events in MATLAB? [closed]

I need to have a better understanding about how to define ODE events. What I know is that if I have my ODE defined as ...
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 ...
1
vote
0answers
472 views

Computing solutions with singularities using MATLAB ODE45

I am new to solving numerically ODES and thus it is difficult for me to judge the reliability/trustworthiness of the results that I have produced for the following problem: I am dealing with a 2nd ...
1
vote
2answers
2k views

How can one describe the accuracy of a Runge-Kutta method?

I am solving a nonlinear ODE with a regular singularity using MATLAB ODE45 or ODE113. I am wondering what precision and accuracy they have and what one can say about the numerical error. The idea ...
2
votes
0answers
253 views

ODE events to switch between 5 equations (friction model)

I am modelling a 1 dof spring-mass-damper system with friction. As first attempt I modelled the friction according to the simple Coulomb model (figure A here http://article.sapub.org/image/10.5923.j....
1
vote
1answer
223 views

Approximate function following interpolation (Matlab)

How do you approximate a function for interpolated points? I use the natural cubic spline to interpolate points as follows for n = 500 points: ...
2
votes
0answers
458 views

Solving constrained BVP, singular Jacobian

The boundary value problem is $$ \begin{cases} \dot{x}_i = \begin{cases} (0.5D^{-1}\psi)_i, \text{ if }(0.5D^{-1}\psi)_i \le 0 \\ 0 \text{, otherwise} \end{cases} \\ \dot{\psi} = 2\Sigma x \\ x(0) =...
5
votes
2answers
374 views

Prescribe solution of a PDE at specific points

I am using MATLAB's PDE toolbox to solve the differential equation $-\nabla\cdot\left(c(x)\nabla u(x)\right) + a(x)u(x) = f(x)$ The particular problem in question is an electrostatic problem, but ...
1
vote
1answer
951 views

How can I solve coupled equations by the method of line(MOL)?

I want to solve 3 coupled PDEs equations. They depend on time, radius and length. I used the method of lines (MOL) and converted them to a system of ODEs in time. Now I want to solve them using MATLAB....
2
votes
0answers
44 views

Constructing 2 fold oversampled cosine basis in MATLAB

So I'm trying to construct a 2 fold oversampled cosine basis in MATLAB. I know how to construct the basis as a square matrix using the following command: ...
4
votes
1answer
468 views

Obtaining column vectors of pseudo-inverse of a matrix

I need to compute the pseudo-inverse of a very large rectangular dense matrix without any special structure or properties. I run out of memory/computing power and have no access to a large parallel ...
1
vote
1answer
181 views

How can i define algebraic equation in differential function in MATLAB?

I want to solve 7 pde's that are functions of time, radius(j) and length(i). I used the method of lines and converted them to a system of odes in time and it becomes something like this: $$dy/dt=((y(i,...
0
votes
1answer
183 views

What is the meaning of this error in MATLAB?

Warning: Failure at t=6.137539e-04. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.734723e-18) at time t. In ode15s (line 730) In ...
0
votes
2answers
4k views

Having smoother contour plots in MATLAB

I have a $80\times200$ matrix, and I want to plot its contents with the contourf command in MATLAB, as follows: \begin{align} &\text{[C,h] = contourf(mat,100);}\\ &\text{set(h,'LineColor','...
1
vote
1answer
76 views

Finite difference for Lighthill source term

I have experimental data containing horizontal and vertical components of speed and I need to evaluate this: $$ \frac{\partial^2}{\partial x_i \partial x_j}\left(v_iv_j\right) $$ Denoting $U$ as ...
2
votes
2answers
408 views

QR decomposition

I have a matrix which is "almost" like an upper triangular just that the last row has non zero elements. And I want to perform the QR decomposition on that matrix. Does anyone know the "name" of such ...
2
votes
2answers
558 views

Generation of random Matrix with Real eigen values

does anyone know any matlab algorithm that can help me generate a random matrix with REAL EIGEN values? Thanks.
2
votes
1answer
128 views

Correct Weights Neural Network

I'm trying to make a neural network using MATLAB. But I'm finding that many problems do not get solved. These are the formulas on which I based: $$ Layers\ in\ Neural\ Network = [0, ..., i, ..., out] ...
0
votes
1answer
4k views

Changing min function to max function for optimization

I want to maximize an objective function using quasi-newton optimization method. But i couldn't find any function for maximizing a function. All inbuilt functions are for minimization. For eg. fminunc ...
0
votes
1answer
833 views

Solving coupled differential equations and Algebraic equation in MATLAB

I want to solve a system of 7 coupled differential equations and 1 algebraic equation in MATLAB with the method of lines. I could do it for each independent equation with some assumptions, but I can'...
3
votes
1answer
328 views

Estimating Regions of Flow in Grayscale Video

I am looking to find an algorithm/method by which I can detect regions of flow in a video. The video is that of a grayscale heatmap where the majority of the image is not in motion. The areas that are ...
3
votes
1answer
421 views

Efficiency of an algorithm

I designed an algorithm to find the global minimum of a function and implemented it in MATLAB. And I also implemented the "Tunneling algorithm" for the global minimum of a function in MATLAB. But now,...
1
vote
3answers
1k views

Unexpected results of MATLAB's ode45

Whilst working with MATLAB recently I encountered something odd that I cannot explain. I was using the ode45 solver to solve a system of two coupled second order ODEs. I wasn't convinced about the ...
1
vote
1answer
2k views

Stairs plot with solid horizontal lines and dashed vertical lines in MATLAB [closed]

I want to create a stairs plot with solid horizontal lines and dashed vertical lines. You can see an example of what I am trying to do in this question (scroll down a little bit). In the example, ...
1
vote
0answers
202 views

Oscillating convergence in my Resilient BackPropagation (RPROP) implementation

I have implemented in matlab a neural network that uses rprop's algorithm to update its weights. Strangely the error on the training set does not converge to a local minimum, but oscillates. Here is ...
0
votes
0answers
46 views

Oscillating convergence plot in my Resilient BackPropagation (RPROP) implementation [duplicate]

I have implemented in matlab a neural network that uses rprop's algorithm to update its weights. Strangely the error on the training set does not converge to a local minimum, but oscillates. Here is ...
5
votes
1answer
694 views

Semidefinite Programming Using CVX in Matlab

I have the following optimization problem $$\begin{align} &\min_{ X_{1}, \dots,X_{k} } \max_{ \theta, \phi } \left|P_{d}(\theta,\phi) - \sum_{k=1}^K \operatorname{Tr}(a_{k}(\theta,\phi)a_{k}^{H}...
0
votes
1answer
184 views

Convex optimization for symmetric (but not positive definite) problems?

Can one employ convex optimization for symmetric but not positive definite problems? I tried using MATLAB's quadprog() function to solve this problem: $\mathrm{min}\frac{1}{2}\mathbf{x}^T\mathbf{H}\...
1
vote
0answers
1k views

BiCopter simulation in Matlab

I derived a bicopter dynamical model with two servos and two BLDC motors. And now am trying to simulate it using Matlab. As base for simulation I used this paper and this code Unfortunately, the ...
1
vote
1answer
620 views

On the fly/matrix free SVD of large sparse matrix

I am trying to apply SVD to large sparse matrices. I already compared the performances of Propack and irlba to those of the matlab svd and ...
0
votes
1answer
224 views

bifurcation diagram MATLAB runs out of memory

I have a 3000 x 2301 matrix 'xfinfin' in MATLAB that I want to plot in the following way: ...
2
votes
1answer
264 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?
0
votes
1answer
1k views

Why is Godunov's scheme (for the advection equation) diffusive?

I'm trying to solve the advection equation $$m_t+(\alpha m)_x=0$$ with $m(0,\cdot)=m_0$ numerically using the first order Godunov scheme. Hence I write $$m_j^{i+1}=m_j^i-\frac{dt}{dx}(m_{j+1/2}^i\...
1
vote
1answer
2k views

Transfer Matrix Method in a rectangular potential well

I am trying to follow an algorithm that is described in Elementary Quantum Mechanics in 1D. I want to compute eigen-energies and functions in bound states in the basic case in rectangular potential ...
1
vote
1answer
1k views

Efficiently extracting a submatrix in Matlab

Suppose I have this matrix in Matlab R2013a M = kron(A,B); where A and B are $N \times N$ ...
4
votes
2answers
131 views

Under what circumstances can two (nearly) identical sparse matrices give different solutions to Mx = b?

Suppose I have two sparse matrices, $A$ and $B$, of size $N \times N$. They each have the same sparcity pattern ("footprint"). They each also have values which in theory should be identical, but aren'...
1
vote
0answers
147 views

"Tunneling" optimization algorithm in Matlab

I was wondering if someone has implemented the "Tunneling algorithm" for the global minimization of a single variable function in Matlab. I am hoping to implement it on $[B, A - \lambda I]$. Where $A$...
5
votes
2answers
200 views

Fast computation on 2D rectangular cartesian grid using matlab

I have a density function $f(x,y)$ on a rectangular domain $[0,1] \times [0,1]$ My domain is divided into cells of length $[0,h] \times [0,h]$, and I want to compute mass of each cell. I am going ...
1
vote
1answer
180 views

Matlab interface for minpack2

Is there a Matlab interface for minpack2? minpack2 http://ftp.mcs.anl.gov/pub/MINPACK-2 consists of Fortran programs , but i would like to call the test problems from matlab. What can i do ?
3
votes
0answers
193 views

Numerically solving a system of partial integro-differential equations in Matlab

Given the following system of partial integro-differential equations $$ \frac{dX(t)}{dt}=\Lambda-\mu X(t)-\beta X(t)Z(t),\\ \frac{\partial Y(t,\omega)}{\partial t}+\frac{\partial Y(t,\omega)}{\partial ...
1
vote
0answers
76 views

fixed point iteration to find out second order non-linear diff equations

I am working on some model analysis, getting two diff equations and after I convert them into matrix form, I have equations looks like $$ [A][X]=C\times\big(\exp([B][X])-1\big), $$ where $C$ is a ...
0
votes
1answer
954 views

How to represent a binary number in a matrix in Matlab?

This is a fairly simple question but my Matlab knowledge is still very limited. I want to take a given binary number (or rather, a bistring) of length $mn$ and generate an $m \times n$ matrix whose ...
1
vote
1answer
66 views

Interpolation of Data Value using Optimized Weighting of Its Features

Assume I have a data set $ { \left\{ {x}_{i} \right\} }_{i = 1}^{N} $ which represents the value of each data point. For each data we have its features $ {f}_{i} \in {\mathbb{R}}^{d} $. The model I ...
1
vote
2answers
55 views

Arranging variable ranges into a cell MATLAB

I have the following simple code v=[]; for i=10:-1:1 for j=0:0.2:5 v(end+1)=i+j; end end min(v) It returns the minimum of vector $v$ whose length in this ...
3
votes
1answer
79 views

Is there an efficient $O(n^2)$ way to estimate in MATLAB a matrix condition number given its LDL decomposition?

Since evaluating a matrix condition number usually takes $O(n^3)$, I wonder whether there is an efficient $O(n^2)$ way to estimate in MATLAB a matrix condition number given its LDL decomposition. ...

1
7 8
9
10 11
16