# Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

762 questions
Filter by
Sorted by
Tagged with
2k views

### parameters estimation

I have to estimate a parameter (K), but I don't know how I can do it. I think by a regression model (minimum least square?), but I'm not sure. The system is: ...
3k views

### Finite Element Method: 2-D Poisson's Equation in Matlab, Gaussian quadrature

I'm having trouble understanding how to code 2-D Poisson's Equation with Dirichlet boundary conditions. What I have thus far is Constructed square mesh with triangular elements Assembled stiffness ...
5k views

34k views

### How to code in Matlab: If an argument is empty, then default to "x" value?

I have a function with a number of arguments, but some of them are optional. 1.) If when the function is called, some are left empty, how do I code it so that it defaults to a specific value? 2.) ...
122 views

### Handling function inputs in Matlab

Say I have a function function u = somefxn(f,n) where f is some function, say ...
824 views

### Nonlinear dynamics: algorithm suggest

I've just started a thesis on nonlinear dynamics which entails numerical analysis of the Duffing oscillator (DO). It's basically just a second order ODE, or equivalently a set of ODEs. Say, after ...
959 views

### What is the runtime complexity of MATLAB operation A*B where A and B are general sparse matrices?

I tried to search the answer and I found that method cs_multiply from this book has been adopted for the purpose of multiplication of two general sparse matrices in MATLAB. In the book it says that ...
326 views

### Clustering data based on the radius of a sphere

I have a data-set that has four columns [X Y Z C]. I would like to find all the C values that are in a given sphere centered at [X, Y, Z] with a radius r. What is the best approach to address this ...
2k views

### Creating spheres In Matlab that change surface color depending data

I am trying to create a series of randomly distributed spheres in Matlab, three will be three sub-sets. I would like each subset to have a different color. I am using a structure because each sphere ...
116 views

### Simple substitutions using symbolic computing in MATLAB

Suppose I have the following MATLAB code. syms a b c1 c2 c1 = a + b + pi*b c2 = a + b + 0.5*b Then c1 gets evaluated to ...
116 views

### Are matlab C library versions backwards compatible?

I have some C++ code that links to matlab2008b. Are matlab 2012a and 2012b backwards compatible with 2008b? If it's not trivially compatible, are there some simple steps to make it compatible?
3k views

### Laplace's equation problem in Polar Coordinates (Edit)

Is there public code in Matlab for solving the Laplace equation in polar coordinates in a circular domain? I tried a lot but my level of Matlab and Mathematica is not good enough, but still not ...
513 views

### Hosting site for a small scientific library

For my research work I have been developing a small C++ library aimed at facilitating the communication between C++ computational codes and Octave/Matlab (when the latter is used for post-processing ...
807 views

### Matlab Pde Toolbox: Plot solution on a line or on a submanifold

I'm using the Matlab pde toolbox to solve a certain elliptic equation in 2D. Solution is fine, although I do need to plot it along a given line, i.e. to cut a planar slice from the 3D mesh ...
545 views

### Numerical Green functions for a nonlinear wave equation

I am trying to put down some code to get numerically the solution of the following PDE: $$\partial^2_t\phi-\partial^2_x\phi+\lambda\phi^3=\delta(x)\delta(t).$$ Of course, there are several ...
2k views

### Why does MATLAB's quadprog outperform MOSEK for my problem?

For a problem I am trying to solve it appears MOSEK's Quadratic Program solver is 100 times slower than MATLAB's Interior Point solver. Has anyone encountered this behavior in the past, or maybe ...
2k views

### What other method can be used to solve differential equations except ode functions in Matlab?

Recently I am taking advantage of the ode45, as well as ode23s, ode15s solvers in ...
328 views

1k views

### good (free) software for producing publishable images?

I am producing 1d and 2d images using Matlab right now for comparison of accuracy against a given model. I need to compare my methods with the standard Gaussian .wfn model and I am going to do that by ...
11k views

### MATLAB Code Evaluation for Least Squares Regression (LSR) [closed]

Below is my own approach to implement the Least Squares Regression algorithm in MATLAB. Could you please take a look and tell me if it makes sense; if it does exactly what is supposed to do? EDIT: ...
139 views

### Numerically designing a periodic 1D curve that maximizes an integral area objective and satisfies value, derivative, and frequency constraints

I need to write MATLAB program (or use an existing one) to obtain Fourier series coefficients. Let's say the series is going to approximate a 1D curve. The boundary conditions are: value of the ...
216 views

### Drawing 3d projection of complex surface

I have a complex surface (real dimension 2) in $\mathbb{C}^2$ with coordinates $(z,w)$ given explicitely: for any $\xi \in \mathbb{C}$ I know points $w(\xi)$ of intersection of surface with complex ...
986 views

### How to compute the optimal ridge regression model

I found R function ridge.cv very useful. I would like to implement the equivalent function in MATLAB. As a starting point, I used MATLAB function ...
387 views

### How to find the number of principal components that lead to the smallest generalization error?

I am working on a paper part of which is the application of validation rules to find how many principal components give us the least generalization error. The concept goes more or less like this: "...
1k views

### Evaluation of multivariate polynomials

I am seeking for an efficient algorithm to compute a multivariate polynomial of a fixed structure, but different coefficients and evaluation points. The question is the same as this one, which ...
590 views

### Manipulating Matrices in Matlab

Suppose I have a matrix $A$ of size $n_1 \times n_2 \times n_3$ Now, I have another matrix $B$ of size $n_1 \times n_2 \times n_3 \times N$ where $N<n_3$ I'd like to create the following matrix ...
30k views

### Ordering of Eigenvalues and Eigenvectors in MATLAB

The following MATLAB function produces the Eigenvalues and Eigenvectors of matrix X. ...
461 views

### problem in output solving two coupled second order differential equations in matlab

I am trying to solve the following differential equations on matlab. (They are the equations obtained from the yang-mills-higgs lagrangian for the hoofy polyakov monopole ansatz). This is my function ...
2k views

### How to find Lyapunov exponent for coupled system

Answer gives a software for calculating conditional Lyapunov exponent (CLE) for coupled oscillators in chaos synchronization. However, it is hard to follow and there is no graphical output of the ...
1k views

### Python syntax for MATLAB/Octave colon operator a:dx:b

I am trying to rewrite some MATLAB/Octave code in Python, and I don't know what would be the nicest or most intuitive way of writing ...
6k views

### MATLAB matrix multiplication (the best computational approach)

I have to make a coordinates transformation between two reference systems (axes). For that, three matrices ($3\times3$) have to be multiplied due to some intermediate axes being used. I have thought ...
1k views

### Usage of DifferentiableMultivariateFunction and NonLinearConjugateGradientOptimizer

I try to use the matlab fminunc functionality in java and found the optimisation functions in commons-math. I have absolutely no clue how to use them right because the example tells nothing about the ...
2k views

### Optimal transport warping implementation in Matlab

I am implementing the paper "Optimal Mass Transport for Registration and Warping", my goal being to put it online as I just cannot find any eulerian mass transportation code online and this would be ...
1k views

### How do I vectorize this 4-D matrix operation in Matlab?

I need to do a large number of matrix operations in Matlab, but one of the matrices is 4-D and my normal instincts for correct vectorization are failing me. Right now I'm using a loop. Maybe somebody ...
3k views

### How to parallelize the computation of eigenvalues of a sparse symmetric matrix in MATLAB?

I have a similarity matrix which is symmetric and sparse. How can I parallelize the computation of the eigenvalues of this matrix in MATLAB?