Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

# 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.

141 questions
Filter by
Sorted by
Tagged with
39 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 ...
44 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 ...
17 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 ...
438 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,...
177 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 ...
59 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 ...
109 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 ...
131 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 ...
60 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 ...
56 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: ...
60 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. ...
47 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 (...
61 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 ...
2k 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 ...
3k 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: <...
1k views

### Computing the sum of squared differences

About Data: 3D data (100x100x20). Computation/Formula and Method: I am trying to compute the sum of squared differences along rows, columns and angles for various time differences. ...
203 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 ...
92 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 ...
189 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 ...
204 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. ...
2k 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 ...
60 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 ...
49 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 ...
691 views

### Implementation of MATLAB's im2col

The function im2col in MATLAB is very useful to vectorize Patch based Image Processing algorithms. The problem is the function isn't optimized and doesn't use C ...
118 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 ...
114 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 ...
614 views

### Array splitting in sub-arrays of consecutive elements

I want to split an array in sub-arrays of consecutive elements. For example, for the array: a=[1 2 3 6 7 9 10 15] I want an output ...
2k views

### MATLAB and Armadillo, hints on translating

i'm rewriting some Matlab code to c++ using armadillo, a libs for linear algebra. really good libs, IMHO. but i had to translate some matlab construct because armadillo isn't matlab. i want to share ...
126 views

### Exporting Matlab Figures as PDF with a Minimal Amount of Whitespace for use in LaTeX

About this code This Matlab function takes in the handle of a figure and exports a PDF containing a vector image of the plot. The caller of this function can opt to even remove the axes if he or ...
263 views

### Spectrum Analysis with Discrete Fourier Transform

Here is a simple implementation of the Discrete Fourier Transform: myFourierTransform.m ...
3k views

### Matlab Code for Convolutional Neural Networks

I am using Matlab to train a convolutional neural network to do a two class image classification problem. I have an imbalanced data set (~1800 images minority class, ~5000 images majority class). As I ...
151 views

### Matlab and WidowX robot arm communication and control

For a class, we needed to control the WidowX arm from Trossen Robotics from Matlab and get as real-time of a feedback as possible. So I came up with a code for the Arbotix Robot-controller which is ...
65 views

### Extracting data from meshgrid output

I am trying to extract data from meshgrid output where zCs is 1000 x 1000 matrix of z values which is produced from meshgrid of s using bin2mat. s is a struct which has x, y, z data. res is 1000. ...
766 views

### Iterative Implementation of Towers of Hanoi

Here is an implementation of Towers of Hanoi based on few observed patterns1 from the easier recursive solution: ...
486 views

### Find first N primes

Here is code that returns the first N prime numbers: ...
69 views

### Avoiding Boundaries if Cases When Filtering Image Matrix

I have the following MATLAB Code which I want to optimize. It's related to an image matrix (2D) which I want to filter. Though it is MATLAB code, the same problem would arise in C code. The problem ...
1k views

### Image Compression Using the Singular Value Decomposition (SVD) with MATLAB

I'm new to both linear algebra and MATLAB. I need help with this code with the objective of compressing image using the Singular Value Decomposition (SVD). The code is currently working, if I run with ...
228 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. ...
2k 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? ...
34 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 ...
186 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 ...
150 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 ...
981 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 ...
70 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 ...
634 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: ...
93 views

### Classifying test data into several classes

The following code is to classify the test data into several classes: ...
188 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 ...
452 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? ...