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.

learn more… | top users | synonyms

-2
votes
0answers
9 views

how the java code be written in matlab? [on hold]

we want to Set n := pt. at infinity ,For i from p - 1 downto 0 do, Set n := 2n but error occur as unexpected matlab expression
0
votes
0answers
15 views

MATLAB / Simulink / Embedded Coder: I would like to combine For-Loops [on hold]

I have a matlab simulink model with a series of DOT Products that could easily be run through a single For Loop but Embedded coder generates a for loop for each DOT Product. Any insight on getting / ...
-2
votes
0answers
10 views

How to obtain transition probability matrix in matrix? [on hold]

Suppose I have a sequence: x= 1,3,3,1,2,1,4,2,3,1,4,2,4,4,4,3,1,2,5,1 and it has five states 1 3 2 4 5. I have to ...
-3
votes
0answers
38 views

How to implement an algorithm in matlab? [on hold]

z(t) is the whitened input vector, y(t) is the output vector, W(t) is the weight matrix, and g is the nonlinearity in the NLPCA criterion. The parameter is a kind of “forgetting constant” that ...
5
votes
1answer
68 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. ...
1
vote
0answers
19 views

Inpainting algorithm using conjugate gradient for colored images using Matlab

I am currently working on an inpainting algorithm : the input is a picture, I apply a Mask (random disposition of dark pixels) and then the algorithm tries to recover the original picture using the ...
2
votes
0answers
39 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: ...
1
vote
1answer
38 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 ...
7
votes
0answers
223 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
49 views

Converting decimal to Roman numerals using MATLAB

I have written a MATLAB function that converts decimals into Roman numerals. ...
1
vote
0answers
51 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
58 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 ...
3
votes
0answers
51 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
47 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? ...
9
votes
0answers
100 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 ...
6
votes
0answers
65 views

Matlab Computer Vision

Im not really certain whether this is OK, but I'm looking for some code advice- particularly around style and efficiency. the code takes a video (a drop onto a fabric surface) and I want it to return ...
3
votes
2answers
61 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
97 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 ...
1
vote
0answers
62 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 ...
0
votes
0answers
26 views

Implement Chambolle dual formulation method in matlab

I would like to implement an Chambolle dual formulation method. The method can be summarize as following This is my implementation in matlab. However, it does not give true result (but combine ...
2
votes
1answer
54 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
244 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
63 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
62 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
68 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
40 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
518 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
563 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
102 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 $$ ...
1
vote
1answer
199 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
70 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
43 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
42 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 ...
4
votes
1answer
88 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
94 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. ...
3
votes
2answers
96 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
1answer
92 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 ...
10
votes
1answer
1k views

Counting Words in Files - MATLAB style

For my Matlab class I'm taking, I was given the task to write a function ReadAndCountWords that takes in the name of a text file (specifically from this zip file) ...
3
votes
1answer
2k views

Run length encoding of vectors in MATLAB: looped version and vectorized version

A project I'm working on requires something akin to run length encoding on a vector in matlab. The data is in the form of a numeric vector, and the output is in the form of two vectors, ...
1
vote
0answers
71 views

Simple class container for hdf5 files

I implemented a simple class container for hdf5 files in matlab. The situation is as follows. Measurement data is saved in hdf5 ...
1
vote
0answers
269 views

Efficient C Code Alternative to 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 ...
1
vote
2answers
134 views

Using brute force to find an energy optimal path for a given amount of time

The code below implements a brute force method to find an energy optimal path for a given amount of time t_aim using recursion (the recursion function is ...
4
votes
2answers
11k views

Trapezoidal rule to approximate the integral of x^2

I've implemented the trapezoidal rule to compute the integral for a function \$x^2\$. I would like to see another style of the same code. It seems Matlab hates for a matrix to be expanded without ...
2
votes
2answers
120 views

90 year data simulation in need of performance increase

I developed some code for my masters project that will simulate 90 years daily data using 1000 different data sets. The code is working fine and gives the correct output that I wanted but the ...
2
votes
0answers
95 views

Kullback-Leibler (KL) distance between inside and outside contour code

I am trying implement the distance measurement between two distributions. The detail is described in here and input image . Let short summarize the idea of the paper: The input image is divided ...
4
votes
1answer
251 views

Vectorize Matlab sum

I have the following Matlab function: function [res] = a3_funct(x) res = 0; for i = 1:size(x,1) res = res + abs(x(i))^(i+1); end end It's ...
3
votes
0answers
1k views

Satellite orbit simulation in Matlab using Runge Kutta 4

I have a satellite orbit simulation in Matlab (Using Runge Kutta 4). It seems ugly and I don't know how to fix it. fx.m file: function v = fx(t,x,vx) v = vx; ...
8
votes
1answer
163 views

Verifying boardgame mathematics with MATLAB

I recently bought this math-based boardgame for my little cousins, and am now trying to verify its design with some MATLAB code. The relevant parts of the game are: A board with numbers from 1 to ...
2
votes
0answers
35 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 ...
1
vote
0answers
55 views

Why does lu-factorization make my program slower?

I'm trying to calculate the smallest eigenvalue of the matrix A by using the "inverted exponentiation method" (see the code). I manage to find the smallest eigenvalue, but when I try to optimize the ...