Question


parpool sorting out the default number of workers
I'm a little bit lost in the default number of workers when parpool() is invoked. My PC is standalone with Intel Processor and W...

3 years ago | 2 answers | 0

2

answers

Answered
What is the efficient way to loop though a multidimensional array in matlab?
The inner most loop should be the fist index, the outer most loop last index. Since MATLAB arranges data with first-dimension v...

3 years ago | 2

| accepted

Question


parfor unable to classify, why?
Can someone explain why the ind2sub first statement triggers the error, but the second works fine? m = 2; n = 3; mycell = cel...

3 years ago | 2 answers | 1

2

answers

Answered
The proper way to sample 3 normally or lognormal distributed variables added up to 1
This will generate 3 random variables positives and sum to 1, with mean 8/10, 1/10, 1/10: nu=[8 1 1]; B=arrayfun(@(n) ones(1,n...

3 years ago | 0

Answered
How does matlab get the combinations that meet certain conditions in the matrix
You don't need MATLAB at all. From 2A1 = A2 A1 + A2, We divide by A1, and factor A2 on rhs to get 2 = A2*(1+1/A1) Meaning 2...

3 years ago | 1

Answered
How to vectorize this piece of code and why doesn't e come out to be zero though it must come out to be zero because u and b are equal?
Not tested but this for i=1:K for h=1:M ae(h,i)=exp(j*2*pi*(h-1)*d*sind(b(i))); %%%%% ae end for p=1:N ...

3 years ago | 0

| accepted

Answered
How to standardize an array so that the maximum value is 1 and minimum is -1 keeping the zero value as zero?
A "smooth" mapping % Data a=randi([-10,10],1,5) pp=pchip([min(a) 0 max(a)], -1:1); normfun=@(a) ppval(pp,a) an=normfun(a)...

3 years ago | 1

Question


Largest lindexing supported by MATLAB?
What is the largest (linear) indexing supported by MATLAB? I would be good to know if there is an official specification for suc...

3 years ago | 1 answer | 0

1

answer

Answered
chol() returns error even the matrix is positive definite.
This statement B1 = d.\B; looks very suspecious to me (the .\ operator), if you remove the dot it will work. Here you do el...

3 years ago | 1

Answered
Implement an arbitrary number N nested for loop
Assuming a not so bug N of 100, and each of your list_to_loop has 2 elements, and you can compute 1000000000 (1e9) Dosomething(...

3 years ago | 0

Answered
Rename variable throughout project/directory
Use grep sed command of linux system. There light be some linux shell (cygwin?) on windows that you can install if you are under...

3 years ago | 0

| accepted

Answered
optimization problem with arrays
Could you try this equivalent expression A=sum(array1.*(array1>0));

3 years ago | 1

| accepted

Answered
Two functions having the same name but one being capital?
"Well, it would appear from the evidence that Matlab is not case sensitive... " No MATLAB is case sensitive "I can't save dupl...

3 years ago | 1

Answered
MatLab parfor slows down when I minimize the MatLab window and start using another program in win10, why?
May be this windows setup has something to do with it https://www.tenforums.com/tutorials/89429-adjust-processor-resources-best...

3 years ago | 2

| accepted

Answered
ICP (Iterative Closest Point) code
There are several codes in File exchange

3 years ago | 0

| accepted

Answered
Vectorize application of xcorr() function
Vectorized method but for-loop with preallocation is faster t = 0:1e-3:1-1e-3; Ts = 5e-2; fd_ = -8:0.1:8; s = rand(size(t))...

3 years ago | 0

| accepted

Answered
Why doesn't evalin('caller','nargout') work?
Obviously it is NOT a normal "function", according to the doc of nargout "nargout returns the number of function output argumen...

3 years ago | 0

| accepted

Answered
Numerical calculation of Hessian for a very complex problem
Never trust fmincon hessian. The hessian output is approximation for solely the goal of determine the descend direction internal...

3 years ago | 0

| accepted

Answered
How do I connect two points from my Adjacency Matrix that are k distance away from each other and display it in my graph?
"You will quickly notice that there are a lot of nodes right next to each other but they do not have an edge connected to each o...

3 years ago | 1

Answered
Is there any matlab function to calculate moving mean square error?
Assuming you have 2 signals S1 and S2 in 1 x N arrays: N = 1000; S1 = randn(1,N); S2 = randn(1,N); n = 10; dS = S1 - S2; ...

3 years ago | 0

Answered
strange performance behavior - microbenchmark
My guess is in the first code, the intermediate result does have to be stored in memory. It can be in processor register or in t...

3 years ago | 0

| accepted

Answered
Generating Exaustive Parameter Combinations
I start with a scalar structure s rather than the structure array, since paramereters might have different lengths s=struct('a'...

3 years ago | 2

| accepted

Answered
Generate random numbers with conditions (min, max, mean, and specific values)
Use this fex https://fr.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-sum r = randperm([16+zeros(4,1...

3 years ago | 0

Answered
An issue with eigenvectors...
Remove the rational option "r" (not reliable) you'll be fine w = magic(3) disp(w) sz=size(w); tm=sz(1,1); p=round(poly(w)...

3 years ago | 1

Answered
Is it worth recoding simpler versions of built-in MATLAB functions to speed up performance?
You are free to strip down anything you want, just don't use the same name as the stock function. As soon as you change the spe...

3 years ago | 0

| accepted

Answered
how to find average value up to current row in Matrix
A = [ 128 8.4 127 8.7 128 8.3 ] A1 = A(:,1); cs1 = cumsum(A1); B = [cs1, cumsum(...

3 years ago | 0

| accepted

Answered
How to look up a smaller array in a larger array while preserving shape
Use convolution to detect matching % I modified it to make example more interesting LargeArray= [0,0,0,0;1,0,0,0;1,0,0,0;1,1,0...

3 years ago | 1

Answered
Array assembly by indexing in a loop
n = 4; x1 = linspace(0,2,n); y1_x1 = sqrt(1-( (x1.^2)/4 ) ); Y1_X1 = []; for i = 1:n Y1_X1 = [Y1_X1, y1_x1(i:end)]; %...

3 years ago | 0

| accepted

Answered
Vectorization of a for loop to increase speed
This returns a matrix, whose elements which do not satisfy the condition and was not computed in your orginal code are marked by...

3 years ago | 0

| accepted

Answered
an Alternative funtion which is faster than "ismember"
If XY is gridded coordinates, then you can use discretize or simple division if they are uniform to determine which grid the riv...

3 years ago | 0

| accepted

Load more