Questions tagged [matlab]

Questions about the numerical programming language MATLAB.

Filter by
Sorted by
Tagged with
2
votes
1answer
415 views

how to know cylinder volume in pixels?

I have a 3D point cloud representing ad object. I use a 3D cylinder to fit this object in the point cloud, so I check if each point is inside the cylinder and, if it is, then I assign a weight to that ...
5
votes
2answers
284 views

I'm having trouble debugging multigrid. What to do?

I've spent far too much time coding and debugging multigrid. While I clearly can't post all of my code as it would be silly to ask someone to go through all that code, is there anything I should pay ...
12
votes
5answers
2k views

Repeatedly solving $\mathbf{A} \mathbf{x} = \mathbf{b}$ with same $\mathbf{A}$, different $\mathbf{b}$

I am using MATLAB to solve a problem that involves solving $\mathbf{A} \mathbf{x}=\mathbf{b}$ at every timestep, where $\mathbf{b}$ changes with time. Right now, I am accomplishing this using MATLAB'...
5
votes
3answers
352 views

PRIMA gives an unstable result?

I am working with Modified Nodal Admittance representation of circuits. I am doing Model Order Reduction using PRIMA on MATLAB. I am considering these circuits as Descriptor State-Space systems. I ...
7
votes
2answers
333 views

Numerical investigation of stability of motion (confinement)

I am trying to find the required specifications of a RF trap, in which a proton can be confined.(trap dimensions, voltage frequency and amplitude used, etc). I have to solve the equations of motion ...
4
votes
4answers
7k views

Efficient assembly of finite element matrix in MATLAB

Question What is the most efficient algorithm for finding a row of a matrix which matches a given row? This is the same as a table lookup based on multiple criteria. Context Finite Element Matrices ...
10
votes
6answers
1k views

Soft Question: Where does Python fit into the picture?

So I've been debating whether or not I should bother learning Python. From speaking with my professors, Matlab seems to be the common language used in applied mathematics/computational science as far ...
26
votes
4answers
9k views

Method for numerical integration of difficult oscillatory integral

I need to numerically evaluate the integral below: $$\int_0^\infty \mathrm{sinc}'(xr) r \sqrt{E(r)} dr$$ where $E(r) = r^4 (\lambda\sqrt{\kappa^2+r^2})^{-\nu-5/2} K_{-\nu-5/2}(\lambda\sqrt{\kappa^2+...
2
votes
1answer
423 views

Customizing Genetic Algorithm on Matlab

The Matlab version is 2012b. I am trying using the built-in GA functionality through the Optimization Tool GUI on Matlab. I want to use bit string chromosome with a given length (for example L=24) and ...
1
vote
1answer
1k views

software request for solving acoustic wave equation

I am searching some libraries or toolboxes (preferred MATLAB) for solving acoustic wave equation in heterogeneous media with time varying source term, i.e. $$\nabla^2 \psi(\vec{r},t) - \frac{1}{c(\vec{...
7
votes
4answers
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.) ...
3
votes
2answers
122 views

Handling function inputs in Matlab

Say I have a function function u = somefxn(f,n) where f is some function, say ...
6
votes
1answer
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 ...
5
votes
1answer
956 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 ...
1
vote
1answer
324 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 ...
4
votes
1answer
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 ...
4
votes
1answer
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 ...
3
votes
2answers
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?
5
votes
1answer
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 ...
9
votes
4answers
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 ...
9
votes
1answer
806 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 ...
7
votes
2answers
544 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 ...
4
votes
1answer
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 ...
6
votes
5answers
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 ...
3
votes
2answers
325 views

Numerical solution of fractional integro-diffrential equ. using collocation method?

problem comes from "Numerical solution of fractional integro-differential , equations by collocation method , E.A. Rawashdeh, Department of Mathematics, Yarmouk University, Irbid 21110, Jordan" $D^...
5
votes
3answers
10k views

Solving two coupled non-linear second order differential equations numerically

I have encountered the following system of differential equations in lagrangian mechanics. Can you suggest a numerical method, with relevant links and references on how can I solve it, and the ...
3
votes
1answer
349 views

Understanding wall time jitter in MATLAB computations

I am studying a research paper on iterative methods to compute generalized inverses of an arbitrary matrix $A$. I am studying the following iterative method: $$Y_{k+1} = Y_{k} + Y_{k}(I - AY_{k}),$$ ...
2
votes
3answers
414 views

derivative of linsolve

Consider a vector $\mathbf{g} \in \mathbb{R}^{m}$ and a matrix $\mathbf{A} \equiv \mathbf{A(g)} \in \mathcal{M}_{p\times q} [\mathbb{R}]$, a function of $\mathbf{g}$. Furthermore, let $\mathbf{S} \...
11
votes
4answers
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 ...
1
vote
1answer
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: ...
2
votes
1answer
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 ...
0
votes
1answer
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 ...
3
votes
2answers
980 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 ...
1
vote
1answer
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: "...
3
votes
2answers
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 ...
5
votes
3answers
589 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 ...
6
votes
4answers
30k views

Ordering of Eigenvalues and Eigenvectors in MATLAB

The following MATLAB function produces the Eigenvalues and Eigenvectors of matrix X. ...
2
votes
1answer
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 ...
9
votes
1answer
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 ...
4
votes
1answer
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 ...
10
votes
3answers
5k 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 ...
2
votes
2answers
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 ...
11
votes
1answer
1k 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 ...
7
votes
1answer
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 ...
4
votes
2answers
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?
3
votes
1answer
2k views

Gauss-Seidel iterations node spacing

I am working on an assignment where I am determining the temperature distribution of a chip on a substrate. When I decrease the nodal spacing the results change drastically. The smaller the nodal ...
8
votes
3answers
2k views

Compute smallest eigenvectors of a matrix

It appears that matlab's eigs is giving me bad approximations of the smallest eigenvectors of a matrix. I assume I can use some slower methods which would also be ...
7
votes
3answers
238 views

Converting from planar polynomial domain to planar polygon

Let's assume we have a planar domain whose boundary can be described with a polynomial curve (like Bezier curves). Now assume that you want to produce a discretization of the boundary, i.e. you want ...
5
votes
2answers
1k views

Matlab: Solving $u_t = f(u) u_{xx} + g(u) u_x + h(u) u$

I am trying to solve the following equation numerically: $$\dfrac{\partial u}{\partial t}=\dfrac 3 x\dfrac \partial{\partial x}\left(\sqrt x \frac \partial {\partial x}(\nu(u,u^2,\cdots,u^k)u\sqrt x)\...
8
votes
2answers
590 views

How many Fourier magnitudes do I have to calculate before an FFT becomes more efficient than a DFT?

I need to compute only a small number of low frequency Fourier components of a complex 2-dimensional array. I'll be computing the same Fourier components over and over again as the input array changes....