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.
1
vote
0answers
5 views
Matlab: speeding up repetitive initialisation with structured data?
I need to speed up this code: it creates a multilinear function. I considered the below methods but no idea which with the largest benefit.
replacing dummy variables with things such as ...
-1
votes
0answers
24 views
Matlab Combinatorics [closed]
Im new in matlab, i hope someone can help me with my problem. I need to make a code to solve this Cobinatoric example. which says that i have vector A which has 10 values 2 of them are 1 and the rest ...
1
vote
0answers
39 views
How to make this more efficient
I have a fitness function where inputs x1 to x14 have values between 1:4. Is there a way to make to more efficient, any suggestions are useful please. I need to get the computation time down. A ...
0
votes
0answers
11 views
Using matlabpool: Is my embedding correct?
A general question: For using matlabpool, I write the line
matlabpool open local 12;
as the first line in my code and the line:
matlabpool close;
as the last. Is this correct?
1
vote
1answer
29 views
Matlab - Fastest way to parallel read many files line by line?
I have a few hundred files in a directory that I need to read in parallel. Namely, the files that have the same name, but different file extensions (.a and .b), but they're pretty much plain text ...
1
vote
2answers
67 views
Rational Approximation for e with Matlab
I've written a program that calculates the best rational approximation for e with a 1, 2, 3, 4, 5, and 6 digit denominator respectively (on Matlab). For a 5-digit denominator it takes about a minute. ...
2
votes
1answer
46 views
Matlab - build a combinatorial matrix from two vectors
I want to define a matrix of values with a very simple pattern. I've achieved it with the code below but it's ugly - very difficult to read (I find) and surely not as optimal, in terms of performance, ...
0
votes
0answers
17 views
How much mxRealloc can affect a C-Mex matlab code?
For these days I was working on C-mex code in order to improve speed in DBSCAN matlab code. In fact, at the moment I finished a DBSCAN on C-mex. But instead, it takes more time (14.64 seconds in ...
2
votes
2answers
41 views
Matlab: Can this triple loop be simplified or eliminated
Matlab profiler throws this horrible bottleneck which is called 700000 times:
for k =1:model.nlf,
for r =1:model.nlf,
KuyDinvKyu = zeros(model.k,model.k);
for q =1:model.nout,
...
14
votes
5answers
928 views
Naive C++ Matrix Multiplication 100 times slower than BLAS?
I am taking a look at large matrix multiplication and ran the following experiment to form a baseline test:
Randomly generate two 4096x4096 matrixes X, Y from std normal (0 mean, 1 stddev).
Z = X*Y
...
0
votes
1answer
303 views
2D convolution in matlab
function C = convolve_slow(A,B)
(file name is accordingly convolve_slow.m )
This routine performs convolution between an image A and a mask B.
Input: A - a grayscale image (values in ...
1
vote
1answer
208 views
Python / Numpy running 15x slower than MATLAB - am I using Numpy effeciently?
Here is some code I wrote in Python / Numpy that I pretty much directly translated from MATLAB code. When I run the code in MATLAB on my machine, it takes roughly 17 seconds. When I run the code in ...
5
votes
2answers
196 views
Drawing random smooth lines contained within a square
I'm trying to write a matlab function that creates random, smooth trajectories in a square of finite side length. Here is my current attempt at such a procedure:
function [] = drawroutes( ...
6
votes
1answer
93 views
how to improve this matlab code using homogeneus coordinates to rotate a matrix?
Currently, I have this code snippet, but it's a little bit slow:
% input image
input_matrix = imread('placa.bmp');
[rows cols] = size(input_matrix);
% rotation
degree = 30;
radians = (pi * degree) ...
2
votes
1answer
50 views
how to get B+ matrix (warshall algorithm) in matlab?
Pseudocode:
// B = nxn binary matrix
// Bm = resulting matrix
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++)
{
if (B[i,j] == 1)
{
for (k=1; k<=n; k++)
{
Bm[i,j] ...
5
votes
1answer
123 views
How to speed up this following code
I am doing my research about scheduling by using Matlab. I am a new Matlab user and I have a problem with time execution of my following code:
clc
clear all
A=8;
B=12;
C=10;
ProcessTime= [ 11 11 11 ...
2
votes
1answer
87 views
Calculate FFT from windowed time-based signal
I have a time-based signal (Raw signal) sampled at 6 MHz and need to analyze it in freq. domain.
I'm learning DSP and this is very first time I work with DSP. Could you please help to check if this ...
1
vote
2answers
166 views
Ways to make this code run faster?
About Data: I have a 3D data (100x100x20) of space and time (c) where first 2 dimensions are concentration values along space while 3rd dimension contains concentration values at different time from 1 ...
2
votes
1answer
235 views
Is this a valid usage of structure assignment in C?
Q: Please comment on the usage of structures and structure assignment operations in C
I am working on converting a MATLAB program to C using BLAS and LAPACK for linear algebra support. The MATLAB ...
2
votes
2answers
366 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 ...
3
votes
1answer
282 views
Generate graph in Matlab
I use this Matlab code:
load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
...
2
votes
1answer
3k views
Matlab code demonstrating use of fft (Fast Fourier Transform)
I posted the following Matlab script in response to a question on Signal Processing. Here is the questions with my answer.
I am looking for comments on how to make this code more instructive for the ...
1
vote
1answer
129 views
how I can change this multi-loop to reduce the computation time in Matlab
how I can change this multi-loop to reduce the computation time?
A is a matrix (5x10000) with the fifth line contains values between 1 and 50 corresponding to different events of an experiment. My ...
2
votes
1answer
63 views
Is there a way to reduce the computation time in this Matlab program?
Is there a way to reduce the computation time in this program that eliminates the columns of a matrix A if for a given column the element of line 4 is equal to the element in row 5:
k=1;
for i=1:4000
...
2
votes
1answer
268 views
how to reduce the computation time for this program matlab?
I started this program for five hours and it has not yet completed. I wonder if we can make changes to reduce the computation time.
I use several for loop and this greatly increases the computation ...
3
votes
1answer
100 views
An efficient way to do a series of product
Ax, Ay, Az: [N-by-N]
B=AA (dyadic product)
It means
B(i,j)= [Ax(i,j);Ay(i,j);Az(i,j)]*[Ax(i,j) Ay(i,j) Az(i,j)]
B(I,j) : a 3x3 matrix.
One way to construct B is:
N=2;
Ax=rand(N); ...
3
votes
1answer
321 views
Code's optimization and speeding up (Legendre's polynomials and functions) in Matlab
I would like to improve this function to reduce the run time and optimize it.
function [Pl,Plm] = funlegendre(gamma)
Plm = zeros(70,71);
Pl = zeros(70,1);
P0 = 1;
Pl(1) = gamma;
...
3
votes
0answers
170 views
Speed up for loops _ Set of linear equations
I have N^2 matrixes. Each one is a 3x3 matrix. I want to concatenation them to a 3Nx3N matrix. I know that the big matrix is symmetric. Evaluation of whole 3x3 matrixes are time consuming so I want to ...
3
votes
3answers
354 views
MATLAB matrix processing
I'm currently working on a project where I am trying to predict a presidential election based on the population density and region of a voter.
I wrote a few MATLAB functions to parse the data, but it ...
