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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
95 views

considering only the instants of trading with the relative price avoiding stale returns

in my MATLAB code I describe a model for price formation with stale returns in this framework there are 2 type of trader: informed traders who always trade in the "right direction" and noise ...
V013's user avatar
  • 13
6 votes
1 answer
169 views

C++ Eigen/Mex function to perform two pagewise convolutions on a 3D matrix with a simple kernel

I am trying to accelerate an algorithm where I am computing a 2D variance of many complex matrices stored as pages of a 3D array in Matlab. My implementation uses a Mex function with the C++ Matlab ...
drakon101's user avatar
  • 181
3 votes
1 answer
57 views

Simple validation and mathematical function in MATLAB

I've made a script (Triangle.m) to calculate the area of a triangle in MATLAB: ...
Freddy Mcloughlan's user avatar
0 votes
1 answer
63 views

Performance Optimization in Matlab

I am working with a rather large data set (upwards of 1 million entries across 3 variables), and need to isolate a subset of that data with specific values in one of the 3 data fields. The data are ...
Andrew's user avatar
  • 1
4 votes
0 answers
39 views

Use XYZ data to create cross sectional profiles across beach terrain, using OS Grid

This might be a slightly long question, but I've recently been doing a bit of R&D on the data processing workflows within the company that I work at and it would be great to see if there are any ...
Adam Johns's user avatar
0 votes
0 answers
65 views

Three-dimensional DCT implementation for GPU computation in Matlab

This is a follow-up question for Three-dimensional DCT spatial frequency components illustration and Parallel 3D Discrete Cosine Transformation Implementation in Matlab. I am trying to perform three-...
JimmyHu's user avatar
  • 3,984
3 votes
1 answer
106 views

String / Char Vector Concatenation Performance Comparison in Matlab

Considering the suggestion of using modern string arrays instead of char vectors proposed by Cris Luengo, I am trying to make a code snippet for performance comparison of these two cases. The ...
JimmyHu's user avatar
  • 3,984
2 votes
2 answers
204 views

No Reference Image Quality Assessment for Video in Matlab

I am trying to perform the No-Reference Image Quality Assessment (NR-IQA) calculation on video. Several NR-IQA methods including Naturalness Image Quality Evaluator (NIQE), Perception based Image ...
JimmyHu's user avatar
  • 3,984
2 votes
1 answer
213 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 ...
drakon101's user avatar
  • 181
2 votes
1 answer
151 views

Cholesky decomposition

This code is Cholesky decomposition in numerical linear algebra. ...
Arvin jmf's user avatar
1 vote
0 answers
35 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 ...
JimmyHu's user avatar
  • 3,984
2 votes
1 answer
66 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 ...
Abdul Azeem's user avatar
1 vote
1 answer
50 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
1 answer
293 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
0 answers
88 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
1 answer
97 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, ...
JimmyHu's user avatar
  • 3,984
1 vote
1 answer
51 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 ...
JimmyHu's user avatar
  • 3,984
3 votes
1 answer
113 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 ...
JimmyHu's user avatar
  • 3,984
3 votes
1 answer
145 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 ...
ConvexHull's user avatar
5 votes
0 answers
971 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: ...
JimmyHu's user avatar
  • 3,984
3 votes
0 answers
34 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 ...
Mate's user avatar
  • 31
5 votes
1 answer
50 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 ...
Matt Bowman's user avatar
4 votes
1 answer
65 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 ...
teeeeee's user avatar
  • 141
1 vote
0 answers
131 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
0 answers
72 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
1 answer
51 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 ...
JimmyHu's user avatar
  • 3,984
1 vote
1 answer
182 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, ...
the_illuminated2003's user avatar
4 votes
0 answers
165 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 ...
Tommaso Belluzzo's user avatar
2 votes
0 answers
35 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: ...
stuckstat's user avatar
  • 129
1 vote
0 answers
161 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 ...
Shankar_Dutt's user avatar
3 votes
2 answers
116 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 ...
Rwy5's user avatar
  • 131
2 votes
1 answer
183 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}...
Aristide Herve's user avatar
1 vote
1 answer
374 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 ...
saad.sawash's user avatar
3 votes
2 answers
60 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 ...
Ankit Jaiswal's user avatar
2 votes
1 answer
752 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: ...
saad.sawash's user avatar
1 vote
1 answer
332 views

MATLAB / vs Python np.linalg.solve, heat diffusion

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 ...
Erdem's user avatar
  • 35
4 votes
1 answer
52 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 ...
WilliamMorris's user avatar
2 votes
0 answers
34 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 ...
mojojojo's user avatar
  • 121
3 votes
2 answers
84 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 ...
Tyler Shellberg's user avatar
3 votes
3 answers
130 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 ...
Tyler Shellberg's user avatar
4 votes
1 answer
2k 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 ...
NAND's user avatar
  • 141
5 votes
1 answer
243 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 (...
Jonathan Lam's user avatar
3 votes
0 answers
65 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 ...
deemel's user avatar
  • 131
4 votes
1 answer
782 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 ...
U. User's user avatar
  • 193
2 votes
1 answer
83 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. ...
Felix's user avatar
  • 263
3 votes
1 answer
447 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 ...
nalzok's user avatar
  • 523
4 votes
1 answer
75 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 ...
G.T.'s user avatar
  • 143
2 votes
1 answer
102 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 ...
Cunningham's user avatar
4 votes
1 answer
432 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 ...
max's user avatar
  • 61
3 votes
1 answer
108 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 ...
ALC's user avatar
  • 33