MATLAB is a high-level language and interactive programming environment developed by MathWorks. It is the foundation for a number of other tools, including Simulink and various toolboxes that extend the core capabilities.
0
votes
0answers
17 views
How can we evaluate a Gaussian in an intensity of an Image?
You can refer to section 4.3.1 in this article if you want.
If pI is any pixel/intensity on this image, and dS is the ...
1
vote
0answers
17 views
Identifying local peaks among some 2D points
The following MATLAB code takes in multiple peak coordinates and heights and eliminates lesser peaks that are within a certain distance threshold of the highest peak of the vicinity. Is there a better ...
0
votes
0answers
27 views
Iterating random motion with constant drift velocity on random times in random direction
I am working on simulating random motion of particles, there are two times exponentially distributed randomly defined as t1 and t2. For time less than t1 particle is in free random motion while for ...
3
votes
0answers
34 views
Shortest distance from point to line segment in 3D
This function returns the shortest distance from a 3D point P to a line segment defined by two 3D points A and B. It projects P onto the line, then checks if this projected point lies between A and B. ...
0
votes
1answer
117 views
Optimizing MATLAB Loop
I have the following code in matlab and since the matrices are huge it takes more than one hour. I wanted to know where the bottle neck is and if there is any way to optimize this and make it faster.
...
4
votes
1answer
50 views
Removing undesired points from a mesh
I have a 3D data set made of a certain number of points (x,y,z) that cover a certain region of space. Using the scatteredInterpolant object I can interpolate this ...
1
vote
0answers
72 views
Convert Java data to Weka-friendly format without using ARFF
recently I've been working on machine learning with Java and Weka, and while I found the .ARFF format easy to understand (you just need an .ARFF file and Weka will do the rest :P), sometimes the ...
1
vote
0answers
52 views
AABB Intersections with Space Partitions, A Sample Code Performance and Reliability
I have originally written the following Matlab code to find intersection between a set of Axes Aligned Bounding Boxes (AABB) and space partitions (here 8 partitions). I believe it is readable by ...
3
votes
1answer
35 views
Selecting indices of a cell array that strcmpi-match the contents of another cell array
I have a Matlab structure with several fields, 3 of which are interesting here:
...
1
vote
0answers
38 views
Matlab compressing image with SVD
I'm new to both linear algebra and matlab and need help with this code. The code is currently working, if I run with e.g sigma_threshold = 10, I get a blurry picture, if I set it to 100 it's even more ...
11
votes
1answer
108 views
Possible “Angle of Incidence” of an RC tail-dragger plane
I am working for an Aero-Design team and we make RC planes that are capable of humanitarian aid. We wished to make a tail dragger and for stability reasons the "Angle of Incidence" (AOI) of the plane ...
0
votes
0answers
55 views
Implementation of Multiclass Perceptron
The following text is from Hal Daumé III's "A Course in Machine Learning" online text book (Page-41).
I implemented the following:
Is the implementation correct?
...
0
votes
0answers
42 views
5
votes
0answers
88 views
Neuroscientific testing
I have written the code below for the following experiment:
Subjects get simultaneous stimulation of left and right thumb and have to tell which one was stimulated "stronger" (with higher intensity, ...
3
votes
0answers
80 views
Classifying test data into several classes
The following code is to classify the test data into several classes:
...
3
votes
1answer
520 views
Parzen window density estimation in MATLAB
This was my C# implementation of Parzen Window Density Estimation.
The following is my implementation of the same in Matlab:
parzen.m
...
0
votes
0answers
22 views
Finding the density of multidimensional random vectors (independence)
I wrote this MATLAB/Octave function to use along with the Bayes Classifier.
Is this the correct approach? Is the following logic correct?
...
4
votes
1answer
275 views
Function for plotting Julia Set
The Julia set is the set of complex numbers z that do not diverge under the following iteration:
$$ z = z^2 + c $$
Where c is a constant complex number.
Different values of z reach infinity at ...
3
votes
1answer
339 views
Plotting the Koch Snowflake
The Koch snowflake is a well known fractal. Beginning with an equilateral triangle, a smaller equilateral triangle is placed halfway along each edge of the shape. This process then repeats on each ...
1
vote
2answers
123 views
Locate a number in an array with a special ordering
Below are two examples of arrays (with a special ordering with odd numbers on one side, and even number on the other side) I have, with some given len:
...
1
vote
1answer
64 views
Counts instances for each category for many Matlab files
This is for machine learning. I have 5 matlab files: AWA, REM, S1, S2, SWS.
Each one has 2 arrays: x and y. ...
4
votes
1answer
74 views
Wavelet decomposition of images
I am working on wavelet decomposition and found a formula for it and wrote it by myself for computation.
The formula is:
$$I_{LH}(i,j) = \sum_{p=1}^{N_L} \sum_{q=1}^{N_H}\ L(p)\ H(q)\ I(i+p, j+q)$$
...
3
votes
2answers
465 views
Optimizing C++ equivalent of Matlab `filter` function
Minimum working example below. The Matlab filter function filters the input data x using a rational transfer function defined by the numerator and denominator ...
2
votes
1answer
74 views
Locate a number in an array with ascending even and descending odd entries
Below are two examples of arrays I have, with some given length:
For some value z, I want to find the column the value is in. ...
3
votes
1answer
112 views
Exporting a table with header and subheader
I have an array matrix, for example A(3,3), I want to make a table with header names like, ['force','mass','acceleration'], the second row contains the units (subheader), ['N','Kg','m/s^2'], and the ...
2
votes
0answers
74 views
Making interpolations in a 4D matrix
I have Matlab code that is very inefficient and I need to run it several times.
The code is basically a big parfor loop which I guess there is almost impossible to ...
10
votes
2answers
302 views
Running a simulation for all unique combinations of a range of parameters
I have written a script which is supposed to call the function at the bottom for each unique combination of values in the parameter vectors. That function is a simulation which I intend to run over ...
1
vote
1answer
37 views
Finding shortest distance between a point and a surface using Lagrange Multipliers
I am new to Matlab. Now I need to find the shortest distance between a given point to a surface, which is describe with a function.
I am planing to implement the method described in the link below ...
4
votes
1answer
68 views
Vectorizing Two Sample Kolmogorov-Smirnov test
I'm implementing the Two-sample Kolmogorov-Smirnov test in MATLAB. I must admit I know very little of formal statistics and was simply trying to implement the description in wikipedia's page.
Right ...
3
votes
1answer
346 views
Matlab implementation of Needleman-Wunsch algorithm
This code (an implementation of the path finding Needleman-Wunsch algorithm), given two sequences, correctly aligns and calculates the similarity of them. For example, given two sequences:
AAA,CCC
...
19
votes
5answers
1k views
Benchmarks of various scientific programming languages for theoretical modelling
For a theoretical modelling course for biology students, I am trying to decide which would be the best technical programming language for doing evolutionary simulations in terms of elegance and ...
1
vote
1answer
118 views
Horizontally concatenating the entries of two matrices, and padding with NaNs
I have two matrices a and b that have, on each line, some values (null or not) and then a bunch of zeros at the end.
I want to ...
5
votes
2answers
84 views
Extract the largest value for each day from a matrix
I have a matrix in which the right-most elements are repeated YYYYMMDD dates in descending order, for example:
...
2
votes
1answer
144 views
Verification of Sudoku boards
A valid Sudoku board has the following properties
The board must be square (n-by-n). Let m = sqrt(n)
All rows must contain the numbers 1-n
All columns must ...
0
votes
1answer
42 views
Assign values to a matrix based on the location of non-zero elements in another matrix
I have a matrix, A containing ones and zeros. I want to create a new matrix B where the non-zero elements are in the same ...
1
vote
1answer
117 views
Merging two square matrices
I would like to optimize a snippet of code, which uses a multiple nested if statements. I am looking for a formula to make it as a combination of multiple arrays ...
1
vote
1answer
329 views
Pattern recognition and machine learning - Bernoulli mixture model
I have been reading the book Pattern Recognition and Machine Learning (Bishop) for a while, and recently I came across this figure, which was created using Bernoulli mixture model on the MNIST dataset:...
4
votes
1answer
88 views
Biometric matching score calculator
I'm working on a biometric matching system and I would like to have few suggestions regarding vectorizing the following code:
...
2
votes
1answer
89 views
Vectorizing a polar coordinate conversion loop in a fingerprint-matching process
I am working on a fingerprint matching technique and it takes a lot of computation time to obtain the result. I am trying to implement the matching process given in A Minutia Matching Algorithm in ...
5
votes
1answer
102 views
Computing the total different between a pixel and its neighborhood
I have C++ code which written for mex in MATLAB. It used to compute the total different between a pixel and its neighborhood (8 neighborhood in my code). The code ran and gave me an expected result. ...
5
votes
2answers
192 views
Visualizing Newton-Raphson method for finding zeroes of a function
I have created a program to visualize the working of Newton-Raphson method to find the zeroes of a function:
newton.m:
...
2
votes
1answer
55 views
Quickly Evaluating MANY matlabFunctions
This post builds on my post about quickly evaluating analytic Jacobian in Matlab.
The key difference is that I am now working with the Hessian and I have to evaluate close to 700 matlabFunctions (...
3
votes
2answers
250 views
Converting decimal to Roman numerals using MATLAB
I have written a MATLAB function that converts decimals into Roman numerals.
...
3
votes
1answer
67 views
Vectorising orthogonal-triangular decomposition for 3D matrix
I am trying to optimise the computation time of my code (for the second time after a first optimisation that gives very good results). Currently, this code is very time-consuming depending on the size ...
3
votes
0answers
266 views
Reading cell array of vectors with h5py
I have a data stored in .mat files, each .mat contains a cell array of vectors of length ~70. I'm trying to read these .mat files in to Python with h5py, but reading just 1000 cells takes about 7 ...
7
votes
1answer
171 views
Segmenting brain images (Dicom format) using region-growing algorithm
I have a list of images in a folder where num denotes the index of image and I used num to run the iterations in a "for loop". ...
0
votes
0answers
167 views
Computing the curvature of a 2D image
I have some MATLAB code that computes the curvature of a 2d image. It computes it iteratively using forward and backward differences. Could you offer some tips for how I can optimize this code?
...
13
votes
2answers
663 views
A* search in MATLAB
I have implemented A* search in MATLAB, but I am looking for ways to increase the speed and optimize it. I have tried using a priority queue but I found it doesn't work that well, so I am using a ...
7
votes
1answer
127 views
Matlab Computer Vision
The code below takes a video as input (a drop onto a fabric surface) and I want it to return the area of the drop.
Currently the code works, but I'm no Matlab expert, and wrote it entirely through ...
3
votes
2answers
112 views
Weighted dice with n faces
Here you find some code that returns the value of a multivariate Bernoulli density function - for a dice with n faces, where each face has its weight (weight must be positive reals, not necessarily ...