Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. 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.

Filter by
Sorted by
Tagged with
0
votes
0answers
4 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: ...
1
vote
0answers
46 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 ...
4
votes
1answer
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 ...
2
votes
0answers
18 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 ...
3
votes
2answers
60 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 ...
3
votes
3answers
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 ...
4
votes
1answer
151 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 ...
5
votes
1answer
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 (...
3
votes
0answers
62 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 ...
4
votes
1answer
209 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 ...
2
votes
1answer
61 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. ...
3
votes
1answer
217 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 ...
4
votes
1answer
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 ...
2
votes
1answer
93 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 ...
4
votes
1answer
198 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 ...
3
votes
1answer
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 ...
4
votes
1answer
474 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
1answer
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 ...
4
votes
1answer
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 ...
1
vote
2answers
631 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 ...
2
votes
0answers
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 ...
3
votes
2answers
272 views

Spectrum Analysis with Discrete Fourier Transform

Here is a simple implementation of the Discrete Fourier Transform: myFourierTransform.m ...
1
vote
0answers
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 ...
1
vote
1answer
66 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. ...
4
votes
2answers
778 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: ...
1
vote
1answer
504 views

Find first N primes

Here is code that returns the first N prime numbers: ...
1
vote
2answers
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 ...
2
votes
0answers
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 ...
4
votes
1answer
210 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. ...
-1
votes
2answers
230 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
159 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
1k 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
72 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 ...
4
votes
2answers
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: ...
1
vote
2answers
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 ...
12
votes
1answer
197 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 ...
1
vote
0answers
460 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? ...
1
vote
0answers
65 views

Multi-layered Perceptron

Solution: Generate Training Set ...
4
votes
0answers
99 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
93 views

Classifying test data into several classes

The following code is to classify the test data into several classes: ...
3
votes
1answer
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 ...
5
votes
1answer
2k 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 ...
4
votes
1answer
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 ...
1
vote
2answers
131 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
85 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
90 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)$$ ...
4
votes
2answers
1k 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
78 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
700 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
86 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 ...