1,297 total contributions since 2006

Professional Interests: neuroscience, physics, mathematics

Answered

Is it possible to do this without for cycle?

% data Y = [1 1 3 2 3 1 1 2] % M = numel(Y) K = 3 % engine T = double((Y(:) - (1:K))==0)

Is it possible to do this without for cycle?

% data Y = [1 1 3 2 3 1 1 2] % M = numel(Y) K = 3 % engine T = double((Y(:) - (1:K))==0)

16 hours ago | 0

Answered

Add zeros to matrices same as length of another matrix

To pad an matrix A with zeros to match a larger or same-sized array B, you can use this: A = magic(3) B = ones(3, 5) ...

Add zeros to matrices same as length of another matrix

To pad an matrix A with zeros to match a larger or same-sized array B, you can use this: A = magic(3) B = ones(3, 5) ...

5 days ago | 0

Answered

how do I convert a cell array of different size cells to a matrix

An easy job for padcat :) c = {{1 2}; {1 2 3};{4 5 6};{10 11 12 12 14}} % rather awkward cell array of cell arrays of n...

how do I convert a cell array of different size cells to a matrix

An easy job for padcat :) c = {{1 2}; {1 2 3};{4 5 6};{10 11 12 12 14}} % rather awkward cell array of cell arrays of n...

6 days ago | 0

Answered

How to convert string to number and process underscores? (e.g. '57_77_' to 57.77)

all in one go: a = '12_23_' v = str2num(strrep(a(1:end-1), '_', '.'))

How to convert string to number and process underscores? (e.g. '57_77_' to 57.77)

all in one go: a = '12_23_' v = str2num(strrep(a(1:end-1), '_', '.'))

6 days ago | 1

Answered

hi everybody , i'm a beginner and don't know how can i convert ascii to a string

A = [51 48 56 ; 73 48 71] str = char(A) % conversion from ascii to character string

hi everybody , i'm a beginner and don't know how can i convert ascii to a string

A = [51 48 56 ; 73 48 71] str = char(A) % conversion from ascii to character string

8 days ago | 0

| accepted

Answered

find max value within set parameters of matrix

If you want to mask out elements of a vector for finding the max, without disrupting the location within the vector, you might c...

find max value within set parameters of matrix

If you want to mask out elements of a vector for finding the max, without disrupting the location within the vector, you might c...

8 days ago | 1

Answered

Array indexing for moving IQR

When N (= number of elements in A) and K (= number of elements to use) are not too large you could create an intermediate (N-K+1...

Array indexing for moving IQR

When N (= number of elements in A) and K (= number of elements to use) are not too large you could create an intermediate (N-K+1...

8 days ago | 0

Answered

Split a matrix at specific row

Use *mat2cell*: M = randi(20, 105,4) ; V = [11 12 11 11 12 12 13 11 12] ; C = mat2cell(M, V , size(M,2)) ;

Split a matrix at specific row

Use *mat2cell*: M = randi(20, 105,4) ; V = [11 12 11 11 12 12 13 11 12] ; C = mat2cell(M, V , size(M,2)) ;

8 days ago | 0

| accepted

Answered

How to find minimal distance between elements?

Without creating a possibly large intermediate N-ny-N matrix or using a possibly slow sort V = [1 8 6 4 2 10] ; W = ncho...

How to find minimal distance between elements?

Without creating a possibly large intermediate N-ny-N matrix or using a possibly slow sort V = [1 8 6 4 2 10] ; W = ncho...

11 days ago | 0

Answered

How to find minimal distance between elements?

By definition the minimum distance is zero because v(i)==v(i) for any element i of the vector v. But I assume you want the mi...

How to find minimal distance between elements?

By definition the minimum distance is zero because v(i)==v(i) for any element i of the vector v. But I assume you want the mi...

11 days ago | 0

Answered

assign values from logial vector to a new matrix with the same size

function B = functionA(A) B = A B(~(A>0)) = 0

assign values from logial vector to a new matrix with the same size

function B = functionA(A) B = A B(~(A>0)) = 0

12 days ago | 0

Answered

Compare segments of a vector

A = [2 2 2 2 2 3 6 3 4 5 1 1 1 1 1 2 3 4 5 6] AA = reshape(A,5,[]) dA = diff(AA,[],2) ix = all(dA>0) ix = 2*fin...

Compare segments of a vector

A = [2 2 2 2 2 3 6 3 4 5 1 1 1 1 1 2 3 4 5 6] AA = reshape(A,5,[]) dA = diff(AA,[],2) ix = all(dA>0) ix = 2*fin...

12 days ago | 0

Answered

Structs fields indexing issue

Parent.Child1.field_1 = [1 2 2 3] ; Parent.Child2.field_1 = [1 3 3 2 3 2] ; Parent.Child3.field_1 = [2] ; A = str...

Structs fields indexing issue

Parent.Child1.field_1 = [1 2 2 3] ; Parent.Child2.field_1 = [1 3 3 2 3 2] ; Parent.Child3.field_1 = [2] ; A = str...

13 days ago | 0

Answered

How to choose all other indices than ones I know?

Here are two options a = [11 12 13 14 15] i = [2 3] b1 = nan(size(a)) b1(i) = a(i) b2 = a i2 = setdi...

How to choose all other indices than ones I know?

Here are two options a = [11 12 13 14 15] i = [2 3] b1 = nan(size(a)) b1(i) = a(i) b2 = a i2 = setdi...

13 days ago | 1

Answered

Average distance of nonzero diagonal to the main diagonal for sparse matrix

In your example, you do not need to check the diagonals at all, just the first row and column of the matrix! A = [0 5 0 1 ...

Average distance of nonzero diagonal to the main diagonal for sparse matrix

In your example, you do not need to check the diagonals at all, just the first row and column of the matrix! A = [0 5 0 1 ...

13 days ago | 0

| accepted

Answered

Average distance of nonzero diagonal to the main diagonal for sparse matrix

Use the second argument of diag? A = sparse(cumsum(triu(ones(5)),2)) diag(A,1)

Average distance of nonzero diagonal to the main diagonal for sparse matrix

Use the second argument of diag? A = sparse(cumsum(triu(ones(5)),2)) diag(A,1)

13 days ago | 0

Answered

How to Return two Matrix of dimension (T,N)

function [G, H] = MyInput(T,N) % do not name this function input, as this is already used by ML !!! G = zeros(T,N) ; % p...

How to Return two Matrix of dimension (T,N)

function [G, H] = MyInput(T,N) % do not name this function input, as this is already used by ML !!! G = zeros(T,N) ; % p...

13 days ago | 1

| accepted

Answered

How to find sampling rate from a signal vector and a time vector?

The sampling rate is the number of samples collected per second. In most typical cases, this is (roughly) a fixed (single) value...

How to find sampling rate from a signal vector and a time vector?

The sampling rate is the number of samples collected per second. In most typical cases, this is (roughly) a fixed (single) value...

13 days ago | 0

Answered

Reordering data based on a separate cell array

B = {'Si','W','Ou','In','We','Ru','Cy','El','St','Jo', 'In'} % example data Collections = { {'Si','St','W'},{'Ou','Jo','R...

Reordering data based on a separate cell array

B = {'Si','W','Ou','In','We','Ru','Cy','El','St','Jo', 'In'} % example data Collections = { {'Si','St','W'},{'Ou','Jo','R...

13 days ago | 0

| accepted

Answered

How to place NaN at diagonal position in cell array?

a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8} sz = size(a) out = repmat({NaN}, sz + [0 1...

How to place NaN at diagonal position in cell array?

a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8} sz = size(a) out = repmat({NaN}, sz + [0 1...

13 days ago | 1

Answered

How to place NaN at diagonal position in cell array?

Put NaNs on the diagonal: tf = eye(size(a))==1 a(tf) = {NaN}

How to place NaN at diagonal position in cell array?

Put NaNs on the diagonal: tf = eye(size(a))==1 a(tf) = {NaN}

13 days ago | 0

Answered

Move all NaN to end of matrix columns.

10+ years ago, I submitted the function *sortlind* to the Matlab File Exchange, which returns linear indices (rather than sub in...

Move all NaN to end of matrix columns.

10+ years ago, I submitted the function *sortlind* to the Matlab File Exchange, which returns linear indices (rather than sub in...

13 days ago | 0

Submitted

sortlind(A, varargin)

sorts input and returns linear indices for parallel sorting

13 days ago | 2 downloads |

Answered

difference between normalization -1 to 1 and 0 to 1

The differences include the min, max, range, mean, median, variance, and many more properties of the normalised data.

difference between normalization -1 to 1 and 0 to 1

The differences include the min, max, range, mean, median, variance, and many more properties of the normalised data.

14 days ago | 0

Answered

exponential fit base 10

Your plot command is incorrect, it seems (f2 is the fit result, not an x-value). So, try this: plot(freq, f2(freq), 'r-') ...

exponential fit base 10

Your plot command is incorrect, it seems (f2 is the fit result, not an x-value). So, try this: plot(freq, f2(freq), 'r-') ...

14 days ago | 0

Answered

How to begin axis from another value and make it a 0 point in plot matlab?

1) change the limits plot(x,y) xlim([23 100]) 2) change the data (not recommended) plot(x,y-23)

How to begin axis from another value and make it a 0 point in plot matlab?

1) change the limits plot(x,y) xlim([23 100]) 2) change the data (not recommended) plot(x,y-23)

15 days ago | 0