Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

0
votes
0answers
31 views

Arpack and Matlab give different values for eigenvalues

I am solving a generalized eigenvalues problem with inversed complex shift: $$(M-\sigma J)^{-1}J \boldsymbol{x} = \boldsymbol{x} \nu \enspace .$$ My matrices are obtained from a finite element ...
0
votes
0answers
4 views

CVX constraint set with varying dimensions

Link to Paper: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf I am trying to solve convex optimization problem in CVX (MATLAB) in which the dimensions of constraints are not fixed. Let me try to ...
1
vote
1answer
21 views

How to nest 2 simple CVX problems? Is it possible at all?

I have the underdetermined outer optimization problem $$\text{min}_{x\geq 0}\quad \|Ax-b_1\|_2^2+\|AT(x)-b_2\|_2^2$$ with $A\in\mathbb{R}^{m\times n}$ and $m<<n=64^2$ or in corresponding CVX ...
1
vote
1answer
35 views

Satisfying Periodic Boundary Conditions while plotting spherical particles inside a cube

I am trying to plot spherical particles in a cube of fixed dimension in matlab. I face a problem here where the center of the sphere is too close to the edge of the cube in this case the rest of the ...
0
votes
0answers
66 views

Integration in MATLAB: Complicated integrand

Can I solve the integral given below using Matlab? $$\frac{C(J)}{C_0} = \frac{2e^J}{\pi}\int\limits_{0}^{\infty} \frac{e^{\frac{\gamma}{2}\left[1 - \sqrt{\rho}\cos(\theta/2)\right]}}{a_1^2 + a_2^2} ...
1
vote
0answers
16 views

radially averaged power spectrum of a binary image does not look like power law

It has been known that Fourier power spectrum somehow obeys power law therefore the slope of the spectrum can be used to calculate the fractal dimension of an image. Many people have used it for ...
0
votes
1answer
57 views

Use line segments to approximate a function

I need to use line segments to approximate a function, f = 1/x. The range of x is from 1 to 2048 with an interval of 1. I will pick 10 locations for x and interpolate y between two adjacent x using ...
0
votes
0answers
79 views

MATLAB: code for restarted gmres

I have a question about Matlab and restarted gmres. I would like to use gmres.m provided here. This code seems to be a popular for the scientific computation ...
1
vote
3answers
98 views

Dealing with errors in non-linear least square problem

I am currently working with a optimization problem involving a non-linear least square problem. I have chosen to use lsqnonlin in Matlab. What follows is a ...
0
votes
0answers
64 views

Frank Wolfe algorithm in matlab

I'm trying to solve the following question : $$ maximize \ x^{2}-5\cdot x + y^{2}-3\cdot y $$ $$ x+y\leq 8 $$ $$ x\leq2 $$ $$ x,y\geqslant 0 $$ By using Frank Wolf algorithm ( according to ...
1
vote
1answer
39 views

Why does `symrcm` create larger band width?

When I run the following (in Matlab) on a sparse matrix $A$, I get larger band width. The symrcm (symmetric reverse Cuthill-McKee permutation) is not guarenteed to ...
0
votes
0answers
31 views

Matlab PDE toolbox

I'm new at matlab and I can't figure out how to make external temperature not constant but as a function. I wanted to use pde toolbox, I choose parabolic type. My external temperature should be ...
3
votes
0answers
48 views

2D wave equation with Mur boundary condition - setting up the RHS and solving (time-steps)

I am trying to solve a 2D wave equation implicitly using FD with central approximations with the following boundary conditions $$\begin{align} &u=2\sin\left(\frac{2\pi}{5}t\right)\quad \text{at ...
1
vote
1answer
66 views

Instability of pdepe in Matlab… boundary conditions?

here is a Matlab beginner banging his head on the wall... I am trying to solve a system of partial differential equations in Matlab, with both derivatives in time and space domains. I am using the ...
0
votes
1answer
81 views

Solving a PDE using Matlab (with varying initial conditions)

I want to solve a 1-D heat conduction PDE using Matlab which looks like $$ \rho c_p \dfrac{\partial T}{\partial t} = \dfrac{\partial}{\partial z}\left( \lambda \dfrac{\partial T}{\partial z} \right), ...
0
votes
2answers
61 views

Compute the intersection of convex sets in Matlab

I'm aware of a Matlab function which take a set of point as an input and select the points which compose the convex hull. Exemples from Mathworks website : ...
0
votes
0answers
35 views

Could anyone help me with dde23 function

I have been trying to graph these equations using dde23 but keep having a error. This is very important for my presentation so I would really appreciate any help ...
0
votes
0answers
51 views

How to solve a nonlinear diffusion equation?

Consider a thin film with a perpendicular applied magnetic field Ha in z-axis. The nonlocal relation between Ha, the self-field Hself (generated by the eddy current J) and the local magnetic flux ...
1
vote
1answer
95 views

Simple integration in Matlab is off

This is an incredibly mundane integration, but for some reason I can't spot the error. I am just performing a simple 3d integration in spherical coordinates which should return the value of 1.0: ...
1
vote
0answers
66 views

Calculate Integral Using Gauss Jacobi Quadrature or otherwise

I need to integrate the following integral: \begin{align} I = \int^z\frac{1-\zeta^2}{(1+\zeta^2)(\zeta-\zeta_l)(1-\zeta_l\zeta)}\prod_{k=2}^{n-1}\left ( \frac{\zeta-z_k}{1-\zeta z_k} \right ...
0
votes
1answer
77 views

Solving PDE with state and time dependent boundary conditions

I am interested in solving the following PDE (heat equation): $$\frac{\partial u}{\partial t} = \kappa \frac{\partial ^2 u}{\partial x^2}$$ In order to solve it, I discretize space uniformly into $N$ ...
-1
votes
1answer
39 views

How do I stop negative numbers and error message: " Failure at t=3.562559e+03. Unable to meet integration tolerances

I am using 8 ODEs in Matlab to simulate the effect of asymptomatic infections in the epidemiology of a vector borne disease. Searching the parameter space under certain settings produces negative ...
0
votes
1answer
80 views

How to speed up fmincon in MATLAB when there are many variables? Alternatives to MATLAB optimization toolbox?

I need to solve an optimization problem with two nonlinear equality constraints. My function evaluation is very fast (less than a second) and I also provide fmincon ...
1
vote
1answer
54 views

How can I plot the Ramachandran regions in MatLab?

I have a scatter plot where I need to shade the Ramachandran allowed regions for aminoacids. I know there is a function that plots them for you, but it is not helpful for my case since I need the ...
0
votes
0answers
74 views

Plane Wave expansion method in matlab

I am a new member of this forum and I was trying to understand Plane Wave expansion simulation in Matlab. So far I cannot understand how to simulate Gz vector in K-space consistently to the numbers of ...
1
vote
0answers
39 views

Using Centroid decomposition instead of SVD

This paper says centroid decomposition (CD) is an approximation to singular value decomposition (SVD). First I do not understand CD yet, since code is available I just want to try it out how it works ...
5
votes
2answers
159 views

Why is Matlab's SVD faster on skinny matrices than on fat matrices?

I noticed something odd today. I have a matrix X that is very skinny (20800 x 200), double precision real numbers, not sparse, ...
1
vote
2answers
116 views

Incremental SVD implementation in MATLAB

Is there any library/toolbox which has implementation of incremental SVD in MATLAB. I have implemented this paper, it is fast but does not work well. I tried this but in this also error propagates ...
0
votes
0answers
76 views

parallel computatioan of a PDE in MATLAB

I want to solve a 1-D PDE $(\partial_{tt} + \alpha\partial_t)u(x,t)=\partial_{xx}u(x,t)-\sin(u(x,t))+f$, using method of lines and for this I defined a spatial grid of about n~1000 points. Since my ...
1
vote
2answers
133 views

How to solve ODEs with constraints using BVP4C?

I am using BVP4C to solve a system of ODEs which is as follows. \begin{equation} \left\{ \begin{aligned} \frac{\partial f(x,y)}{\partial x} &- ...
3
votes
1answer
124 views

Software for triangulating a point set (with restrictions)

I want to triangulate a point-set like the one below. I would like the triangulation of the point-set to have the following properties The triangles must have as vertices the black and orange ...
0
votes
1answer
76 views

MATLAB: Backslash operator using symbolic variables with an overdetermined system

I have an overdetermined system (too many equations), expressed as Ax=b, in MATLAB. When I try to solve it using A\b, I receive the error: ...
2
votes
0answers
92 views

1 D Diffusion equation FDM with different layers

I'm trying to solve this particular equation $\frac{\partial u}{\partial t} = \frac{\partial}{\partial x} \big[D_{i}(x)\frac{\partial u}{\partial x} \big] + S(x,t)$ where the $i$ index denotes ...
3
votes
1answer
67 views

Integration including bessel function

I’m trying to evaluate an improper integral of a 0th order Bessel function of the first kind using Matlab: v = integral(@(x)besselj(0, x), 0, Inf) which returns ...
1
vote
1answer
42 views

Is it possible to locate an image in a video using MATLab?

I'm not a huge programmer, but if it'll save me lots of time, that's when I code (given that it's possible). I know MATLab has a Computer Vision Toolbox, so my question is: is it possible to program ...
0
votes
2answers
156 views

How can I reduce integration tolerance in matlab?

It was said in a comment that I should recude integration tolerance to eps. What does this Matlab error message mean? I read the manual and I still don't know how to do it. Can you please tell me how ...
1
vote
1answer
58 views

Sparse linear system of certain type

Let $n_1,n_2 \in \mathbb{N}$ and $n=n_1n_2$ and $b\in \mathbb{R}^n$. I have a SPD-matrix $A=(a_{i,j})\in \mathbb{R}^{n \times n}$ with $a_{i,j}=0$ if $|i-j| \notin \{0,1,n_1\}$. Can we solve the ...
1
vote
1answer
85 views

Creating Periodic Noise in Matlab and then adding it to a signal

I am not sure if this is the correct forum for this question but here it goes. If this is not the correct forum please direct me to the appropriate forum. I wish to add some periodic noise to a 1-D ...
1
vote
0answers
51 views

Solving condensate density problem in MATLAB

I want to solve for $n_{0}$ for a fixed value of $n$, lets say $n=1$ $$ n= n_{0}+ \dfrac{1}{2}\int_{-1/2}^{1/2}dq\left(\dfrac{e_{q}+Un_{0}}{\hbar\omega}-1\right) $$ where $e_{q}=2[1-cos(2\pi q)] $ ...
0
votes
0answers
14 views

Forcing variables to take specific values in ode15s [duplicate]

I am solving a system of ODE's. Instead of using M * dC/dt = F(C,t), I would like to specify the jacobian and instead use M * dC/dt = J * C. Since the problem has Dirichlet type boundary condition, i ...
3
votes
2answers
137 views

Why do structured and unstructured discretizations give different errors?

It is necessary for me to solve a Poisson problem with a numerical method on a square domain with two types of triangular mesh: uniform triangular mesh (using uniform distribution nodes on square) and ...
0
votes
1answer
47 views

Interpolating 3D Array non-monotonic data in MatLab

I am working on creating a program for simulations where three variables are parametrized, and we modify one parameter while keeping the other two constant. An example array looks like this when ...
-1
votes
1answer
80 views

Dirichlet boundary condition

I am trying to solve ODEs in matlab using ode15s. Instead of specifying ODEs in the format M * dC/dt = f(C,t) where C is a function of x and t. I want ...
0
votes
1answer
45 views

For loops in matlab with a specific starting point

I have the following definitions long = 1000; init = 500; N = init+long; T = init+1:N-1; T1 = init+2:N; I then fill the vectors ...
1
vote
1answer
139 views

Raising elementwise a large symmetric, positive definite matrix to a power in Matlab

I have created a large positive definite (thus symmetric) matrix in Matlab. For sake of simplicity, let's assume that the matrix has the following form: $K= \left[ \begin{array}{ccc} k_{11} & ...
2
votes
1answer
64 views

find the exact solution ref The finite element method using matlab by Kwon and Bang [closed]

The results found are as under how do we find the exact solution ref The finite element method using matlab by Kwon and Bang.Page no 280-281 Example no 8.10.1.
2
votes
0answers
40 views

Bracket Algebra, Straightening Algorithm

My apologies if the question is simple. I need to write a code for straightening algorithm. Which includes defining bracket algebra. I tried to write it in CoCoA-5, but it wasn't possible because ...
0
votes
0answers
129 views

3D animation of a vector field (ParaView)

I am trying to create an animation of a 3d vector field in ParaView. All my data is in three matrices (201 x 201 x 201) corresponding to vectors components in x,y,z directions. And it's calculated in ...
5
votes
0answers
116 views

Is there a faster method to compute the geometric series of a matrix?

I want to calculate the geometric series of a matrix $A$: $$S=I+A+A^2+\dots+A^n$$ and then apply to a vector $v$, $Sv$. I've done it in Matlab with a loop and I think it's quite efficient applying ...
0
votes
0answers
48 views

How to speed up calls to integral2 in matlab

I am performing a 2D integral for each time step of a calculation. The problem is that I need to vary through all possible permutations of a1,a2 (which always ...