Questions about the numerical programming language MATLAB.

learn more… | top users | synonyms

0
votes
0answers
21 views

Lagrange function minimize

Suppose f(x) is a function we want to choose x so as to minimize f(x)=Ax-b under constraints x>=0. A is a Matrix (n*m) not symmetric and x and y are a vectors. I do f(x)=A'Ax-A'*b and then I want to ...
-5
votes
0answers
19 views

Crank nicolson method to solve couple nonlinear pde [on hold]

how to solve couple nonlinear pde using crank nicolson method...I need a matlab code for this..plz help me.
0
votes
0answers
59 views

Matlab PDE toolbox problems specifying geometry with large size differences [on hold]

My problem comes up in an attempt to calculate dislocation bias factors in bcc Fe. I am following a paper by Chang et al found at Science Direct. To do this, I am trying to solve an elliptic PDE ...
0
votes
1answer
59 views

Solving Time dependent Schrodinger equation using MATLAB ode45

The Schrodinger equation for time-dependent Hamiltonian is $$i\hbar\frac{d}{dt}\psi(t) = H(t)\psi(t) \, .$$ I try to implement solve the Schrodinger equation for time-dependent Hamiltonian in ODE ...
3
votes
0answers
26 views

Defining Cauchy principal value in MATLAB (or Scilab/Maple)?

How to define a variable which is an integral involving cauchy principal value inside in any computer programming language? I want to know how to break down the procedure step by step from a ...
3
votes
1answer
119 views

Approximating improper integral with FFT

In d'Halluin et al. (2005) (http://imajna.oxfordjournals.org/content/25/1/87.short) the authors claim that the correlation integral $$ I(x) = \int_{-\infty}^{\infty} V(x+y) f(y) dy $$ can be ...
4
votes
1answer
126 views

Computational time not proportional to integration interval in ODE-solver?

I am running octave and i have been trying ode45, ode54, ode23 etc to integrate the equation ` $$Q''(t) = B\cos(Q)\sin(\omega t)$$ $$Q(t=0)=0.$$ When the time interval to be integrated increases, the ...
1
vote
0answers
37 views

Conservative Short Sales Portfolio Optimization with MatLab code help

I'm trying to solve the optimization problem below with MatLab, but I'm unsure of how to modify the constraints in the quadprog function (or how to add the constraints with the Portfolio object). In ...
0
votes
1answer
66 views

Conjugate symmetry in MATLAB?

I have a large vector with complex numbers. How do I check whether it a conjugate symmetry vector? If not, is there any way to transform it?
0
votes
1answer
45 views

Discretized matrix from the integral kernel function

Recently, I read a paper [1] and then I want to handle the two-dimensional linear integro-differential equation \begin{equation*} -\triangle u + q\Big(\frac{\partial u}{\partial x} + \frac{\partial u}{...
0
votes
0answers
66 views

Stiffness emerges as number of ODEs increases

I want to solve a system of ordinary differential equations with Matlab. I need this to solve a mechanical engineering related problem. If $n$ is the number of degrees of freedom of my mechanical ...
0
votes
1answer
108 views

Nice plot of f(x)

A user has this nice graph of f(x) on his profile and I want to learn how to do it in matlab or Gnu octave. ...
1
vote
0answers
44 views

Difference between Brent's and Alefeld-Potra-Shi for root finding

I need to find the (unique) root of a nonlinear function $f(x)$, $x \in \mathbb{R}$. For the record, $f(x)$ is the CDF of a probability density minus a constant $0 < p < 1$ (I am inverting the ...
1
vote
0answers
41 views

Solving system of constrained linear and non-linear equations in MATLAB

Solving system of constrained linear and non-linear equations in MATLAB I'm solving a FEM problem in MATLAB with use of the direct stiffness method. The problem is now formulated as a system of nn ...
-4
votes
2answers
92 views

How to write a function that its plot is like a “M” in MATLAB

I wrote a code in MATLAB that solves parabolic equation of two space (heat equation:$u_t = u_{xx} + u_{yy}$ )with ADI (Alternating direction implicit) method (finite difference method). Now in order ...
0
votes
1answer
82 views

Integer programming with Matlab

I'd like to know how to solve in MATLAB the following integer optimization problem : $\underset{B,D}{\arg\min} \Vert{Y-XDB}\Vert_{2}$ where $X,Y$ are given matrices. The constraint is the following ...
-1
votes
2answers
70 views

Stability of matrix equations in MATLAB

Is there a method to check for unconditional stability or positive-definiteness of large matrices in MATLAB? For example, I know that matrices with property M (positive main diagonal elements and ...
6
votes
0answers
56 views

Tucker factorisation to compare multiple PCA decompositions?

This is an entry level question for multiway matrix decompositions. I have a set/population $k$ of entities (here biological cells) for each of which I also have a number ($l$) of flavours of length $...
0
votes
1answer
46 views

COMSOL: get list of eigenfrequencies [closed]

In COMSOL, is there a way to get it to export a txt file with all the eigenfrequencies found during an eigenfrequency analysis? I suppose that it could be done through the MATLAB interface or through ...
0
votes
0answers
35 views

lbfgsb quit at the first iteration

Recently I've been working on the implementation of an algorithm, which need me to solve a bounded optimization problem with quality constraints. So I downloaded a Matlab wrapper for lbfgsb. It is L-...
1
vote
1answer
133 views

How to solve the problem without using symbolic computation

I have the following simple nonlinear equations with two unknowns only: $$\left\{ \begin{array}{c} \int_1^2{\dfrac{ e^{{a_1} x+{a_2} x^3}}{1+x^2}} \, dx=1 \\[13pt] \int_1^2{ x^2 e^{{a_1} x+{a_2} x^...
0
votes
2answers
34 views

Difference between Data structure objects and cell array objects in matlab

I want to know what are the differences between two data structures in MATLAB: Structure Arrays and Cell Array. In what circumstances we can use each of them?
0
votes
0answers
56 views

Most efficient and practical way to avoid calculating inverse matrix?

So I've heard about the LU decomposition applied to avoiding calculating the inverse of a matrix and how it's so much more efficient than the typical inverse calculating functions in numerical ...
0
votes
3answers
196 views

$\exp(\ln(x))-x\neq0$?

Analytically, the expression $$\exp(\ln(x))-x \enspace,$$ should give 0. However, in Matlab, it does not. x = linspace(1, 10, 10); exp(log(x)) - x; for $x \in ...
0
votes
0answers
63 views

Need help writing the code for the following optimization

I need to find $X$ for which the following expression is minimized: $$ \min ||Y - F^{-1}(X)||_2 + ||X||_1 $$ where $Y$ is an array (of length approx 44000, an audio sample I will be reading using ...
0
votes
0answers
19 views

How can I simulate a PCM (erythritol) charge and discharge with Matlab?

I need a Matlab code in order to simulate a PCM. I should use 1D explicit heat equation [(d2T / dx2) = (1/a) * (dT / dt)].
5
votes
0answers
80 views

Galerkin FEM error when using even number of elements

Intro: I am developing a Galerkin FEM code in matlab - starting small with a simple 1D ODE. The equation I'm trying to solve is: $$a u_x = cos(x), x \in [0, 2\pi]$$ Which has a known exact solution $$...
1
vote
0answers
62 views

Numerically computing Viscous Burger

I am trying to solve the Viscous Burgers equation using the spectral method. $$u_t+uu_x = Du_{xx}$$ where $D$ is a constant (chosen to be zero) and with the initial condition $$u(x,0) = exp(-x/0.2)^2$$...
3
votes
1answer
84 views

Numerically computing the advection equation

I am trying to write a program to compute the advection equation. $$u_t +u_x = 0$$ I use the spectral method for the spatial derivative $u_x$ and the leapfrog method for the time derivative $u_t$. ...
1
vote
1answer
60 views

Handling figures built for different parameters in Matlab

I couldn't find a simple answer to this thing I'm trying to do in Matlab. I have a function file that does some calculation for a given parameter a: ...
1
vote
0answers
44 views

Scaling a vector-valued non-linear function for numerical optimization/minimization

I am trying to minimize a non-linear vector-valued function in MATLAB. As a test case for my code, I try to minimize a function whose solution I know apriori. The problem is that one of the ...
1
vote
2answers
43 views

MATLABs double arithmetic

this is a classical problem, but I need help to pinpoint what I am missing. Problem: In MATLAB (exp(1) + 10^12) - 10^12 gives you a double which equal to e, up to 5 correct digits. But I thought ...
0
votes
0answers
121 views

Two stage rocket launch using Runge-Kutta 4 gives weird results

I want to see how much fuel it takes to send a rocket into space. By changing the initial fuel, after I pass 2150 tones, the speed vy becomes negative. Even by ...
0
votes
0answers
79 views

How to solve a set of 1st order 1D PDEs in Matlab?

i have already asked something similar to this once but sadly i wasn't able to get a complete answer, so i remain stuck on this problem. the Matlab function pdepe seems to only be able to solve 2nd ...
1
vote
2answers
195 views

Code for shallow water equation

I want to write a MATLAB code for Roe solver for 1D shallow water equations. Is there anyone who can help me with that?
2
votes
1answer
137 views

Matlab integral with vectorized bounds, without using a loop

I have a simple question that I wasn't able to find an answer to. I have a function f(x) where x is some vector, for example: <...
2
votes
1answer
49 views

Is more robust to digit cancellation the sum operator or the mean operator?

Note: this question is not strictly related to Matlab or any other environment (even though I would prefer that you refer to my Matlab code). I've n = 10000 ...
0
votes
1answer
165 views

How to solve my PDE's in Matlab?

I need to solve a set of 5 PDEs for functions $u(x,t)$. I looked up the Matlab function pdepe. It looked perfect for my case, until I read the line: $f(x,t,u,\...
0
votes
0answers
115 views

Preconditioned Conjugate Gradient linear system solver in MATLAB

I have been trying to use the MATLAB's pcg() function to minimize an energy functional. Converting minimization problems to the solution of a linear system is ...
3
votes
1answer
112 views

Solving linear systems with ill-conditioned matrices

As per suggestions of the people from MathOverflow, I'm reposting my question here: I'm currently trying to solve a linear system $Ax = B$, where the matrix $A$ is ill conditioned (i.e. nearly ...
0
votes
1answer
153 views

Introduction to Lattice Boltzmann methods [closed]

I am trying to learn the Lattice-Boltzmann method and was looking for some good beginner resources explaining the method. I have been looking at some codes online, but have been having trouble ...
0
votes
1answer
74 views

How to create node to node lumping

I have been doing finite element analysis using Matlab. I look for many examples and tutorials producing only the stiffness matrix letting elements being weightless. However, in my case i need to do a ...
1
vote
2answers
99 views

How to solve a constrained optimization problem using minFunc or minConf

I am trying to solve the following optimization problem: \begin{align} &\min\limits_{s} \rm{tr}\left(S^T S\right) + \mathrm{tr}\left(\left(S^T S\right)^{-2}\right)\\ &\text{subject to }\rm\...
1
vote
1answer
51 views

Calculate the intersection of two matrix kernels in MATLAB

If we have a discrete saddle point problem with the coefficient matrix $$ \mathcal{A} = \begin{bmatrix} A & B^T \\ B & 0 \end{bmatrix}, $$ then $\mathcal{A}$ is invertible, supposing $...
3
votes
3answers
105 views

How to assemble Global matrix (for coupled) problem?

I'm trying to assemble global matrices for the following system. $$ \begin{bmatrix} K& Q\\ Q^T&S \end{bmatrix} \begin{bmatrix} u_h\\ p_h \end{bmatrix} = \begin{bmatrix} f_u\\ f_p \end{...
0
votes
3answers
275 views

Numerical simulation of a reaction-diffusion system on MATLAB with finite difference discretization of spatial derivative

I have a model of a system which consists of diffusing reactants and intermediates. For each variable, $u_i$, the final representative equation looks like the standard reaction-diffusion form: $$\...
0
votes
1answer
87 views

How can I generate 3D unstructured mesh on MATLAB

I have been looking to do a 3D mesh for a shallow tunnel FE analysis. The output of mesh node orientation along the element should be counter clock wise direction. How and which material helps me best ...
0
votes
0answers
23 views

How to apply asymptotic matching condition in bvp4c?

I want to know how to write the code to apply asymptotic matching condition? In the paper, it is stated that they apply asymptotic matching condition for the range of ...
0
votes
0answers
57 views

Calculating derivatives

I have this formulation and want to calculate its derivatives using a mathematical software, either Matlab, Mathematica or anything else. Is there any way by which I can obtain the second equation ...
1
vote
0answers
20 views

How to find active region in treepartition Matlab object

I am trying to identify a non-linear plant using the identification toolbox of Matlab. In particular I would like to identify a non-linear arx model, where the nonlinearities are expressed by means ...