# Questions tagged [matlab]

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.

172 questions
Filter by
Sorted by
Tagged with
144 views

### Fractional indexing and interpolation to reconstruct an image

I have a c++ project written as a Matlab Mex program that is constructing an image composed of IxJ pixels. Each pixel value is calculated by finding the contributions to that pixel from all the ...
• 121
70 views

### Cholesky decomposition

This code is Cholesky decomposition in numerical linear algebra. ...
1 vote
21 views

### Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab - follow-up

This is a follow-up question for Calculate distances between two multi-dimensional arrays in Matlab and Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab. For ...
• 3,302
37 views

### Recursion to generate fractal

I used recursion to generate fractal and got the desired result but I think my code can be better I started using MATLAB a few days ago and since than trying and learning new things. Now this code ...
1 vote
35 views

### Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab

This is a follow-up question for Calculate distances between two multi-dimensional arrays in Matlab. Given a set SX $$S_{X} = \{ { X_{1}, X_{2}, X_{3}, \dots, X_{n} } \}$$ where n is the count of ...
• 3,302
1 vote
83 views

### Calculate distances between two multi-dimensional arrays in Matlab

In question "Dictionary based non-local mean implementation in Matlab", the Manhattan distance between two three-dimensional structures can be calculated by ...
• 3,302
1 vote
67 views

### Dictionary based non-local mean implementation in Matlab

Given a dictionary including multiple X-Y pairs where X, Y are both three dimensional structure. dictionaryBasedNonlocalMean function return a ...
• 3,302
1 vote
43 views

### Finding max number and location in multidimensional array in Matlab

I am attempting to find the maximum value and its location in multidimensional array using Matlab. There are functions findMax3, ...
• 3,302
1 vote
24 views

### Batch generating histograms of images in Matlab

I am attempting to plot histograms for batch of images in Matlab. The file structure of input images and the experimental implementation are listed as below. File structure of input images The matlab ...
• 3,302
461 views

### NIQE score and PIQE score calculation for batch of images in Matlab

There are some image quality assessment methods for "no-reference" image quality analysis. Here, I am attempting to calculate the NIQE score and PIQE score for batch of images in Matlab. The ...
• 3,302
84 views

### Three-dimensional DCT spatial frequency components illustration

I am attempting to make three-dimensional discrete cosine transformation spatial frequency components illustration. The 3D cubes is used to present the level of each coefficient. The more bright the ...
• 3,302
62 views

### Matlab vs C: Tensorproduct or Vec-trick (multiple times)

I am searching for a more efficient way to calculate the so called vec-trick used in Tensor algebra, see Wikipedia. Introduction: Suppose you have a matrix vector multiplication, where a matrix C ...
• 133
90 views

### Two dimensional bicubic interpolation implementation for dlarray in Matlab

This is a follow-up question for Two dimensional bicubic interpolation implementation in Matlab. While I am working on neural network designing, I want to compare the effects between using padding and ...
• 3,302
513 views

### Two dimensional bicubic interpolation implementation in Matlab

I am attempting to implement two dimensional bicubic interpolation algorithm in Matlab. The input is a two dimensional array and the output is the interpolated result. The test input matrix: ...
• 3,302
28 views

### MatLab: Plotting Output Electric Field Spectrum

Goal This code combines two matrices, diagonalizes that matrix, and finds the right and left eigenvectors, right and left eigenvectors are normalized with respect to each other, then it is multiplied ...
• 31
39 views

### Simulate transmission spectrum of extreme ultraviolet laser pulse through laser-dressed finite sample (MATLAB version)

I am currently participating in research on transient absorption spectroscopy and four wave mixing. In the experimental design, an extreme ultraviolet (XUV) laser pulse and infrared (IR) laser pulse ...
61 views

### Finding number of possible arrangements of books on a shelf with a Monte-Carlo approach

The Problem I am trying to determine numerically how many possible ways a number of books can be arranged on a shelf. Specifically, there are x3 categories "physics", "sci-fi", and ...
• 141
1 vote
102 views

### Parallel 3D Discrete Cosine Transformation Implementation in Matlab

I am trying to implement 3D Discrete Cosine Transformation calculation in Matlab with parallel computing parfor. The formula of 3D Discrete Cosine Transformation is ...
• 3,302
1 vote
65 views

### 3D Non-local Mean Algorithm in MATLAB

This is a follow-up question for GetNeighborhood function for 3D cells structure in MATLAB. Based on the existing 2D non-local algorithm, I am attempting to implement 3D non-local mean algorithm in ...
• 3,302
1 vote
42 views

### GetNeighborhood function for 3D cells structure in MATLAB

I am attempting to implement a GetNeighborhood function in order to get a specific region from inputCells by ...
• 3,302
1 vote
21 views

### How to code a minimization problem with constraints and indices into PSO within MATLAB? [closed]

I have a GAMS code that represent a mathematical model which depends delay (i,p) for each job i and the period of day p. So, I have indices for represent delay and objective is minimizing of summing ...
121 views

### Calculation of the Distance Matrix in the K-Means Algorithm in MATLAB

Purpose of the code : To assign the corresponding label of the centroids to the points which are close to it. Below is a graphical (2D) example. Variable X is a matrix, rows represent the points, ...
158 views

### Cross-Entropy Minimization - Extreme Code Performance

I'm working on a multivariate cross-entropy minimization model (for more details about it, see this paper, pp. 32-33). It's purpose is to adjust a prior multivariate distribution (in this case, a ...
27 views

### Implementation of calculation of gamma for RBF SVM

I have implemented the calculation of gamma value for RBF SVM as described in Liu et al (2012) [https://ieeexplore.ieee.org/abstract/document/6246300]. Here's a snapshot of the example from the paper: ...
• 129
1 vote
144 views

### Custom Model intended to be used for Curve Fitting. Vectorization vs For Loop and jit numba capabilities

I am new to community and please pardon me if I didn't provide information as intended. This code is supposed to be creating a custom model which will be used with ...
100 views

### Optimizing nested loop for calculating geodesic distance

I segmented an image into N superpixels and constructed a graph based on that in which each superpixel is considered as a node. The information about neighbor superpixels is stored in ...
• 141
134 views

### Vectorizing equations for fsolve

I have a system of 49 equations and 49 unknowns ($x_{1},...,x_{49}$). All equations have the following form. \\$x_{s}\sum_{r=1}^{R}\sum_{t=1}^{T}a_{s,t}b_{rs,t}=\sum_{r=1}^{R}\sum_{t=1}^{T}a_{r,t}...
1 vote
280 views

### My implementation of the Union-Find data structure in MATLAB

I was assigned the connected components labeling (CCL) algorithm and in order to implement the CCL algorithm I first had to implement the Union-Find algorithm. This is my try at it, any review and ...
• 307
57 views

### Reduction of time for the code of sorting RGB and Depth images according to timestamp values

I have RGB Images, Depth images and OpenPose Images(generated from RGB Images). The number of RGB and Depth images are different so I have to find the exactly which RGB images corresponds to which ...
1 vote
34 views

### Calculating the term of dfdeta [closed]

I am trying to improve the time running of this code. Some dummies variable is defined and it is just some part of a lot of lines of code, but I tried it with dummies variables. It takes too much in ...
• 11
517 views

### My custom implementation of MATLAB's imdilate

I have been assigned to implement the morphological dilation operation without using MATLAB's imdilate, and I came up with the following solution: ...
• 307
1 vote
86 views

### MATLAB / vs Python np.linalg.solve, heat diffusion, Why Python is slow? [closed]

I am solving a simple 1D steady heat question using spectral method. I am a long time MATLAB and Mathematica user and trying to learn Python. I compare only linear solving times and Python is way ...
• 27
51 views

### Kernel based conditional increments of many stochastic processes

I have written this function is part of a research project that involves analyzing time-series data from stochastic processes. We have a small number (from 1 to 3) of independent observations of a ...
30 views

### Simulation of splitting particles (MATLAB - Fortran) [closed]

I'm trying to write a code where a charged particle (charge=+20 called dimers), after a certain time, will split into a neutral particle and a smaller charged particle (charge=-10 called monomer). I ...
• 121
70 views

### Finding paths between triangles efficiently in 3D geometry #2

This post is an update of the one from here. I've updated the code and a couple pieces of the post itself. I've been writing some functions used to find paths between two types of triangles - alphas ...
122 views

### Finding paths between triangles efficiently in 3D geometry

An update to this post can be found here I've been writing some functions used to find paths between two types of triangles - alphas and betas. Alphas are triangles that have been in a zone we ...
1k views

### Getting saddle points of a matrix

My homework assignment: Write a function called saddle that finds saddle points in the input matrix M. For the purposes of this problem, a saddle point is defined as an element whose value is ...
• 141
143 views

### Simple SVM in MATLAB

I'm studying SVMs and wrote a demo in MATLAB (because I couldn't get a quadratic programming package to work correctly in Python). Right now it's simple and can only do linearly-separable cases (...
• 235
63 views

### Optimising multiplication of matrix rows with matrix slice/page

I've recently vectorized most of the code for an optimization problem but this one still eludes me. As the procedure and not the actual values are important here, I have replaced the original matrices ...
• 131
711 views

### Artificial Neural Network Classifier in Matlab

I am trying to build a neural network classifier. I have created a neural network with 1 hidden layer (25 neurons) and 1 output layer (1 neuron/binary classification). The dataset I am using has the ...
• 183
72 views

### Applying a function to columns of two matrices producing their combinations

I made a short snippet for applying a function f that takes two arguments (vectors) to columns of two matrices producing all possible combinations of those columns. ...
• 263
389 views

### Draw common tangents to two circles interactively in MATLAB

Requirement After a user draws two circles with their mouse successively, the program should draw all common tangents, if any, to them. Here is my implementation ...
• 551
68 views

### Vector operations

I want to perform the following procedure: I have two vectors x=[1,2,3] and y=[5,7,9] I want to take first element of ...
• 143
96 views

### Applying correction to a time series in Matlab

I face a computation efficiency problem. I have a time series of a non-monotonically drifting variable, that is measurements of objects going through a machine (where the measurement is made) in a ...
354 views

### Calculate Mersenne prime numbers in MATLAB

A Mersenne prime is equal to (2^n - 1), where n is an integer. 31 is a Mersenne prime since 31 = 2^5 -1. I need to write a code that calculates Mersenne primes between 1 and 10,000. Lastly I'm not ...
• 61
90 views

### How to pass pre-generated values to an anonymous function to speed up a fit?

In Matlab I am using the combination of fit and fittype function (from the curve fitting toolbox) to fit a signal using an ...
• 33
792 views

### Matlab IIR filter implementation

I need to implement the Matlab filter(b,a,x) function in Java. Before I do this, I would like to rewrite the function in Matlab before translating into Java. So far,...
1 vote
83 views

### vectorize 2D gradient with spatially varying bins

The following code takes in some values ssh and solves the equations for the geostrophic motion (slide 8 here). The main part of the code is the computation of the ...
• 255
142 views

### Generating locations based on a power-law distribution of distance from their origin

I have a small function that gets a vector of N linear indices locations in a matrix and returns N new locations in the same matrix. For each of the input locations, a random angle tet and a distance ...
• 163
1 vote