Community Profile

# Richard Brown

### Massey University

202 total contributions since 2008

Maths Lecturer at Massey University. Working on high performance computing and modelling.
Professional Interests: numerical analysis, modelling, computer vision, mathematical biology

View details...

Contributions in
View by

Submitted

fitellipse.m
Fit ellipses to 2D points using linear or nonlinear least squares

Submitted

nearestneighbour.m
Computes nearest neighbour(s) by Euclidean distance

How to create a sparse matrix with such specifications?
*edit* This version is wrong, but leaving so comment below makes sense density = 0.01; % For example m = 10000; n = 1000...

5 years ago | 0

count groups of elements and distances between them
A = [6 6 6 4 4 4 4 4 6 5 5 7 7 7 8 9 8 7 0 0 0 0]; x = diff([find(diff([0 ismember(A, [0 6]) 0]))]); L = x(1:2:end); ...

5 years ago | 2

Positive Semi-definite Matrix Problem
You're just going to have to live with it. Your matrix is PSD to double precision. If you look at the magnitude of the "zero" ei...

5 years ago | 1

vectorizing calculation of eigen values of a large multi-dimensional array
You'll get a bit of a performance boost simply by looping over linear indices rather than nesting (this is more than twice as fa...

5 years ago | 0

Reduced row echelon form technique
It'll be a difference between yours and MATLAB's choice of tolerance. Your matrix should be rank 2, however I notice that MATLAB...

5 years ago | 0

| accepted

Evaluation of matrix element of a linear differential matrix equation by constrained least square fitting
Assuming you have multiple |X| and |X'| vectors that you're trying to fit your matrix to, your problem can be posed as a constra...

5 years ago | 0

| accepted

displaying indexed values correctly
Similar to what you asked before, I think what you want is to find the |Vb| element that is closest to half of |Vb_ev|, and then...

5 years ago | 0

| accepted

finding closest values in array
If I understand correctly, you want to find the |pH| value in your array closest to 4.756, and pull this value out, together wit...

5 years ago | 5

| accepted

How can I create sparse symmetric positive definite linear system?
|sprandsym| is what you want. m = 50; density = 2/m; % for example rc = 0.1; % Reciprocal condition number A = spr...

5 years ago | 1

| accepted

Sign differences in QR decomposition
It's only unique up to the signs of the rows of |R|. If you want to enforce positive diagonals of |R|, and thereby get a unique ...

5 years ago | 1

| accepted

Output argument "Clus_Area" (and maybe others) not assigned during call to
Check that the line if AR > 0 is doing what you intend. This will only evaluate if all entries of |AR| are positive. T...

5 years ago | 0

How to use variable value as an input to the function?
You can very probably get away with just passing |template1| and |template2| themselves (not trying to create references to them...

5 years ago | 0

The error message says it all. You're only computing one derivative in |my_function|. You need to define |ys(1)| and |ys(2)|...

5 years ago | 1

How do I efficiently calculate a scalar distance with 3d geometry?
You should use |hypot|. It also has better numerical stability. *edit* sorry, you're in 3D. That obviously won't work. You c...

5 years ago | 0

Generating a particular sequnce of numbers
Also comparable, but not (quite) faster n = 1:(d*(d+1)/2); a = ceil(0.5*(-1 + sqrt(1 + 8*n))); out = a.*(a + 1)/2 - n...

5 years ago | 2

Generating a particular sequnce of numbers
Even faster: k = 1; n = d*(d+1)/2; out = zeros(n, 1); for i = 1:d for j = i:-1:1 out(k) = j;...

5 years ago | 2

replace all instances of |lenght| with |length|

5 years ago | 0

End of function slow - Matlab Profiler
Pretty sure you'll find it's the overhead for the function call

5 years ago | 0

| accepted

Fit and Plot Gaussian Function
Sure, rather than trying to fit a distribution (which is not what you want), just fit the Gaussian itself. Generate some nois...

5 years ago | 0

Surface area from a z-matrix
OK, well how about splitting each quadrilateral into two triangles, and just summing up the areas? I'm sorry there's no way I ca...

6 years ago | 0

| accepted

Argmin with several minimums
It doesn't feel very satisfactory, but this will do the trick I = find(A == min(A))

6 years ago | 0

Projecting Points to a new Basis
I'm not sure what your question is asking because you're missing a symbol off your question. But I think you mean if n is not eq...

6 years ago | 0

How can I use "symbfact" to speed up several consecutive Cholesky factorizations?
You can't (unless something has changed recently). When I had to do this, I ended up working with the C code in CSparse directly...

6 years ago | 0

| accepted

Simple solution to a simple problem
Try 1./(1 + 9*x.^2) i.e. a '.' before the division

6 years ago | 0

Piecewise Cubic Hermite Interpolating Polynomial (PCHIP)
It works perfectly x = [5.8808 6.5137 7.1828 7.8953]; y = [31.2472 33.9977 36.7661 39.3567]; pp = pchip(x...

6 years ago | 0

| accepted

Sparse and nonspare QR
Sorry to take a while, busy week. Neither are wrong. You'll notice that the only difference in the outputs is that the sparse ve...

6 years ago | 0

| accepted

Sparse and nonspare QR
On my system they match (up to the signs of the rows, as you'd expect). m = 20; n = 10; X = sprand(m,n,0.3); Rs...

6 years ago | 0