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.
1
vote
1answer
44 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
62 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
196 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
50 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
74 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
64 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
269 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
0answers
9 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
59 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
50 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
794 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
114 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
81 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
70 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
38 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
116 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
189 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
82 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
75 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
86 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
1answer
106 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
53 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 (...
8
votes
0answers
267 views
Decompose polarimetric SAR covariance matrices in MATLAB
I want to apply the following code on 3 images of the sizes 676×718, 1430×1440, and 5576×9444, but the code is too slow even for the 676×718 image.
...
3
votes
2answers
94 views
Converting decimal to Roman numerals using MATLAB
I have written a MATLAB function that converts decimals into Roman numerals.
...
3
votes
1answer
66 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
138 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 ...
6
votes
1answer
88 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
80 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
259 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
103 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
85 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 ...
1
vote
0answers
158 views
Linear interpolation Matlab to C++
I don't have a strong mathematics/Matlab background. I would like to convert this Black level correction function from Matlab to C++. Please comment about on the code style and correctness of my ...
4
votes
1answer
79 views
Function that reorders the columns of a matrix
The objective: Given an m by n matrix, I have written a function in Matlab that reorders the columns of the matrix to output linearly independent columns; other/redundant columns. Basically, it just ...
2
votes
1answer
66 views
Searching for log entries in SQLite that involve a particular IP subnet
This reads a huge database (SQLite) and extract any IP address similar to ip_base:
...
3
votes
1answer
370 views
Currying in Matlab
As MATLAB has a hard maximum of 10 input arguments it's possible, but ugly, to implement a curry function in this manner:
...
0
votes
1answer
74 views
Matlab to C++ percentile clipping
I have a 2D matrix in Matlab and I want to convert the Matlab code into C++.
In C++ I have int* channel_gr. The commented code is the original Matlab code.
Is ...
0
votes
1answer
63 views
Plotting a trigonometric function appears to be too slow
This calculates the mobility and it's derivative of one element. If I calculate with 1 value of w, it's very fast.
...
2
votes
1answer
91 views
Dealing with input and output in Matlab
I just wrote a program which performed some elementary set operations as you can see below. It's the first time I have used input and output of text files so I am mainly looking for critique on that, ...
1
vote
0answers
47 views
Matlab bins with two features: calculation and plotting
I have the following code in Matlab, which is supposed to do what I asked in this SO question. The idea is to:
Divide the temperature deadband of each agent (they are different between agents) into <...
2
votes
0answers
703 views
fftshift implementation for OpenCV
I'm trying to implement fftshift from matlab for OpenCV. Can you please review the correctness of my algorithm? Have I missed something? Also, is there a better and faster way to do it?
...
1
vote
0answers
896 views
Simple Priority Queue
I am trying to implement A* search on a grid in MATLAB. I am currently using a priority queue class I found here, but it's a bit slow. I tried to write this simple priority queue class in MATLAB:
<...
4
votes
1answer
103 views
Mean of the squares of differences for a large matrix
I have tried to obtain speed gains by transferring Matlab calculations to C and call it using .mex. My goal is to operate on a matrix \$B\$ which has roughly the dimension 10000x1000
$$
\frac{1}{\...
1
vote
1answer
250 views
Optimize matlab triple for loop
I have a large matrix samples, I want to make another matrix sampleProb which is the same size, but modified as below:
...
4
votes
1answer
81 views
Implementation of Logistic Regression
Is this kind of vectorized operations the most efficient way to do this in matlab? Any critics about my code? Am I doing something wrong (i tested several times, I think it works). Notice that I use J ...
3
votes
1answer
50 views
Integrate the product of four infinite series functions
I wrote the following code to integrate the product of four functions.
Two of the functions are hypergeometric functions and the other two are incomplete gamma functions. I have written each function ...
1
vote
0answers
43 views
Iteratively process an identically named file all subdirectories and plot analysis to root directory
This script can successfully go through all of the subdirectories in a root directory, and then process a specific file that exists in all of them and output the file in the root directory as a .png ...
5
votes
1answer
91 views
Vectorization for temperature simulation
I'm new to Matlab and I would like to know tips in order to reduce the processing time of such program. The scheme of the actual code is very similar to typical C++ code and I would like to vectorize ...
2
votes
1answer
101 views
Speeding up loop-rich Matlab function to calculate temperature distribution
I would like to speed up this function as much as possible in Matlab.
This is part of a bigger simulation project, and as it is one of the most called functions within the simulation, this is crucial.
...
7
votes
3answers
168 views
Improving Matlab function within big simulation
I have a very big Matlab simulation project in my hands, which I wanted to optimize, since I'm running it many times to tune parameters and the like.
Using Matlab's ...
1
vote
2answers
105 views
Improving excution time for list and sampling in Python
Here is my code for generating edge list based on Price model algorithm. I think there have two points to reduce execution time:
use proper data type
use faster random sampling
Originally, I used ...