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
1answer
18 views
Is this a valid way of computing autocorrelation?
I am a beginner in Digital Signal Processing and I was trying to compute and plot an autocorrelation.
I've wrote this piece of code:
r = [zeros(2,1); y(1:98,1)];
r = r.*y;
and I wished to know if ...
0
votes
0answers
49 views
Matlab: fast equal comparison for structs?
The structs have a sparse implementation for multilinear functions. This part is from the mlf_add function that adds multilinear functions together like x+y+(2x)=3x+y. In order to do that, I need to ...
1
vote
1answer
46 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
vote
0answers
47 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 ...
1
vote
2answers
33 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
150 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
158 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
234 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, ...
2
votes
2answers
66 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,
...
17
votes
5answers
3k 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
680 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 ...
5
votes
2answers
470 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
245 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
162 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
76 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
131 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
114 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
220 views
Computing the sum of squared differences of the concentration profile
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
248 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
534 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
354 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
4k 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
167 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
82 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
335 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
103 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
526 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;
...
4
votes
1answer
197 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
384 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 ...