Réponse apportée
How to effectively get the mean for every three consecutive outputs?
If you want to avoid reshape, nd arrays, etc... C = [zeros(1,size(A,2)); cumsum(A,1)]; M3 = diff(C(1:3:end,:),1,1)/3 ...

presque 8 ans il y a | 0

Réponse apportée
A question about generating a matrix
clear A A(n) = 1

presque 8 ans il y a | 0

Réponse apportée
reduce execution time in matlab
Please try to replace the DCCA with this function function [CovXY,VarX,VarY]=DCCA_vec(Data1,Data2,n) X=cumsum(Data1)...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
HISTCOUNTS a true replacement of HISTC?
Third solution, may be the best in term of speed/memory % replacement of [n,i] = histc(x,edges,dim); [~,~,i] = histc...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
how to index zeros or remove zeros for indexing?
D=zeros(length(A),length(B)) D(A>0,B>0)=C(A(A>0),B(B>0))

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Frequency of data occurrence using histc
You might take a look at uniquetol()

presque 8 ans il y a | 0

Réponse apportée
Logical indexing based on intervals
For general case, meaning without any assumption about the intervals; you can use a function in <https://fr.mathworks.com/matla...

presque 8 ans il y a | 0

Réponse apportée
Find closest value in array y of n columns corresponding to values from array x with m columns.
A_time = A(:,1); B_time = B(:,1); [At,ia] = unique(A_time); ib = interp1(At,ia,B_time,'nearest','extrap'); C = A(i...

presque 8 ans il y a | 1

| A accepté

Réponse apportée
HISTCOUNTS a true replacement of HISTC?
Another solution of replacement, still long, but consumes less memory than my first solution at the cost of array permutations: ...

presque 8 ans il y a | 0

Réponse apportée
HISTCOUNTS a true replacement of HISTC?
OK, here is the answer of my own question. The replacement of [n,i] = histc(x, edges, dim); is [~,~,i] = histco...

presque 8 ans il y a | 1

Réponse apportée
How to generate a 2D sphere matrix and not a disc
phi=linspace(0,2*pi,512); theta=linspace(0,pi/2,512).'; x=cos(phi).*cos(theta); y=sin(phi).*cos(theta); z=ones(siz...

presque 8 ans il y a | 2

Question


HISTCOUNTS a true replacement of HISTC?
Since few latest releases we get the code warning "histc is not recommended. Use histcounts instead". However how to replace ...

presque 8 ans il y a | 4 réponses | 1

4

réponses

Réponse apportée
Generate Gaussian Mixture Distribution samples for PEM
% Characteristics of your GM distribution mu = [1,2,5] sigma = [0.2, 0.3, 0.4]; A = [5 3 2]; % number of samples...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Logical indexing based on intervals
any(EMG_times>=t_comb_5(:,1)' & EMG_times<=t_comb_5(:,2)',2) Or if you run for old matlab release: any(bsxfun(@ge,EMG...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Binning of data except from histcounts?
ndivisions=4; n = length(A); partnum = floor(1+(0:n-1)/n*ndivisions); n1 = accumarray(partnum(:),A(:)==1)

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Binning of data except from histcounts?
A = [0 0 1 1 1 0 0 0 0 NaN NaN 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1]; [U,~,J] = unique(A); inan = find(isnan(U),1,'first');...

presque 8 ans il y a | 0

Réponse apportée
How to generate numbers from probability mass function?
A more generic method: p = [0.2 0.3 0.5]; v = [3 7 10]; n = 10000; c = cumsum([0,p(:).']); c = c/c(end); ...

presque 8 ans il y a | 1

Réponse apportée
How simulate correlated Poisson distributions
One way is to apply <https://en.wikipedia.org/wiki/Poisson_distribution Knuth's Poisson generation> using two <http://comisef.wi...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
generate uniformly distributed points inside a hexagon
Here is a generating method without rejection R = 3; centerx = 3; centery = 7; n = 10000; % Generate uniform points in th...

presque 8 ans il y a | 2

Réponse apportée
How to output a mexFunction input without copy
"How do I define an output vector as an input vector which has been modified in a C routine called by the mex function?" You ...

presque 8 ans il y a | 0

Réponse apportée
How to vectorize for loops
x = x(:).'; f = sum(x.^2.*(length(x):-1:1))

presque 8 ans il y a | 1

| A accepté

Réponse apportée
I am trying to generate uniformly distributed points inside a hexagon of specific centre (other than the origin). Any help is most welcome, thank you.
Here is a method without rejection: R = 3; centerx = 3; centery = 7; n = 10000; m = 3; X = rand(m-1,n) ....

presque 8 ans il y a | 1

Réponse apportée
What is the complexity of ismember function?
I run this code (R2018b) by changing the length of B is ISMEMBER(A,B), length A fix. It shows clearly the timing is NOT proport...

presque 8 ans il y a | 0

Réponse apportée
interp1 function gives an error ''Error using griddedInterpolant The grid vectors must contain unique points.''
[x,~,J] = unique(z_Sd(:,1)); y = accumarray(J, z_Sd(:,2), [], @mean); vq1 = interp1(x,y,0.3157);

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Declaring plot arguments/options beforehand
lineColor = {'k', 'r', 'b', 'm'}; linestyle = {'-'; '--'; ':'; '-.'}; for j = 1:4 options = {'color',lineColo...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
How to fill a matrix with numbers from a to b ?
A = 4:2:40

presque 8 ans il y a | 3

| A accepté

Réponse apportée
What is the complexity of ismember function?
"Is there a better function in matlab (with lower complexity) that i can use that assuming the input is sorted" You could do ...

presque 8 ans il y a | 0

Réponse apportée
Check if nxm block of 1s is inside binary matrix
[i,j] = find(conv2(MM_bin,ones(3,6),'same')==3*6); I was testing with MM_bin in your MATFILE file which is an 2D array ...

presque 8 ans il y a | 0

| A accepté

Réponse apportée
Check if nxm block of 1s is inside binary matrix
[i,j] = find(conv2(MM_bin,ones(3,6),'same')==3*6); will return you all the positions (i,j) with 3*6 submatrix of ones cente...

presque 8 ans il y a | 0

Réponse apportée
mixing randomly existing values in a vector
>> a=[1 1 1 1 1 1 0 0 0 0]; >> r = a(randperm(length(a))) r = 1 1 0 1 0 1 0 ...

presque 8 ans il y a | 0

| A accepté

Charger plus