Answered

how to reverse a random permutation of a matrix to get back the original matrix?

key1 = randi(398,4,5); s = size(key1); p = reshape(randperm(numel(key1)),s); O = key1(p); [~,ii] = sort(p(:));...

how to reverse a random permutation of a matrix to get back the original matrix?

key1 = randi(398,4,5); s = size(key1); p = reshape(randperm(numel(key1)),s); O = key1(p); [~,ii] = sort(p(:));...

3 days ago | 0

| accepted

Answered

how to use "ln" function on each elemnets of the matrix?

Here |yourmatrix| - double array. log(yourmatrix)

how to use "ln" function on each elemnets of the matrix?

Here |yourmatrix| - double array. log(yourmatrix)

6 days ago | 0

| accepted

Answered

Frequency of unique rows

a = [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 2 0 0 0 2]; [aa,~,c] = unique(a,'rows'); out = ...

Frequency of unique rows

a = [0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 2 0 0 0 2]; [aa,~,c] = unique(a,'rows'); out = ...

7 days ago | 1

| accepted

Answered

How to find a specific row in the matrix

M = [1 8 11 2.1; 2 10 12 1.8; 1.5 9 10 2.2; 1 9 10 1.9]; [~,ii] = min(M(:,end)); out = M(ii,1:3);

How to find a specific row in the matrix

M = [1 8 11 2.1; 2 10 12 1.8; 1.5 9 10 2.2; 1 9 10 1.9]; [~,ii] = min(M(:,end)); out = M(ii,1:3);

7 days ago | 1

Answered

Changing block row matrix to block column matrix?

[EDIT] B = 2; % the number of blocks [m,n] = size(c); out = reshape(permute(reshape(c,m,n/B,[]),[1,3,2]),m*B,[]);

Changing block row matrix to block column matrix?

[EDIT] B = 2; % the number of blocks [m,n] = size(c); out = reshape(permute(reshape(c,m,n/B,[]),[1,3,2]),m*B,[]);

7 days ago | 2

| accepted

Answered

How to concatenate the rows of char array containing 8-binary string ?

a = string('10111011'); b = string('10101010'); a + b

How to concatenate the rows of char array containing 8-binary string ?

a = string('10111011'); b = string('10101010'); a + b

8 days ago | 0

Answered

How do merge two vectors into one, like in intersect. but now with a small margin

out = A(ismembertol(A,B,1,'DataScale',1));

How do merge two vectors into one, like in intersect. but now with a small margin

out = A(ismembertol(A,B,1,'DataScale',1));

8 days ago | 0

Answered

How to Import excel document with alot of sheets that does not ignore date in first column

fn = 'Path_to_your_file\MachineLearning.xlsx'; [~,sheet_name] = xlsfinfo(fn); sheet_name = strrep(sheet_name,' ','_'); ...

How to Import excel document with alot of sheets that does not ignore date in first column

fn = 'Path_to_your_file\MachineLearning.xlsx'; [~,sheet_name] = xlsfinfo(fn); sheet_name = strrep(sheet_name,' ','_'); ...

8 days ago | 0

| accepted

Answered

what should be the program for following output?

>> a0 = {'Sr_no' 'Threshold' 'TP' 'TN' 'FP' 'FN' 'FAR' 'FRR' 'GAR'}; a=[1 0 0 100 0 100 0 1 0 2 0.1 19 100 0 81 0 0.81 1...

what should be the program for following output?

>> a0 = {'Sr_no' 'Threshold' 'TP' 'TN' 'FP' 'FN' 'FAR' 'FRR' 'GAR'}; a=[1 0 0 100 0 100 0 1 0 2 0.1 19 100 0 81 0 0.81 1...

8 days ago | 0

Answered

how can i apply 1 of k coding scheme on 2D MATRIX

C = randi([1,3],2,4) [m,n] = size(C); k = max(C(:)); out = zeros(n,k,m); [ii,kk] = ndgrid(1:m,1:n); out(sub...

how can i apply 1 of k coding scheme on 2D MATRIX

C = randi([1,3],2,4) [m,n] = size(C); k = max(C(:)); out = zeros(n,k,m); [ii,kk] = ndgrid(1:m,1:n); out(sub...

8 days ago | 0

| accepted

Answered

Finding neighbours in a matrix

Let |a| - your double array. m = size(a)+2; b = nan(m); b(2:end-1,2:end-1) = a; iii = reshape(1:numel(b),m); ii...

Finding neighbours in a matrix

Let |a| - your double array. m = size(a)+2; b = nan(m); b(2:end-1,2:end-1) = a; iii = reshape(1:numel(b),m); ii...

9 days ago | 0

Answered

sum of consecutive months value in an array

a = [1988 6 223.12 1994 7 1033.0 1994 8 464.67 1995 9 251.33 1997 6 121.41 1997 8 624.58 1999 9 221.60 20...

sum of consecutive months value in an array

a = [1988 6 223.12 1994 7 1033.0 1994 8 464.67 1995 9 251.33 1997 6 121.41 1997 8 624.58 1999 9 221.60 20...

9 days ago | 0

| accepted

Answered

table name res5500 ,row size 762,three column, third column each row have different length,compare the value of each row is same or different. count number of same row and different row, please help me

f = fopen('path_to_file\res_5500.csv'); c = textscan(f,'%s','delimiter','\n'); fclose(f); n = cellfun(@numel,re...

table name res5500 ,row size 762,three column, third column each row have different length,compare the value of each row is same or different. count number of same row and different row, please help me

f = fopen('path_to_file\res_5500.csv'); c = textscan(f,'%s','delimiter','\n'); fclose(f); n = cellfun(@numel,re...

9 days ago | 0

Answered

How do I create a loop to increment the number of terms of a function?

m = @(x)1+a(:).'*(x - b(:)) use >> a = [1 2 3 4 5]; b = [6 7 8 9 10]; m = @(x)1+a(:).'*(x - b(:)); ...

How do I create a loop to increment the number of terms of a function?

m = @(x)1+a(:).'*(x - b(:)) use >> a = [1 2 3 4 5]; b = [6 7 8 9 10]; m = @(x)1+a(:).'*(x - b(:)); ...

11 days ago | 0

Answered

why do I need to add eps ?

To avoid the uncertainty of |"0/0"| situation when calculating |z|. When |x = 0| and |y = 0|.

why do I need to add eps ?

To avoid the uncertainty of |"0/0"| situation when calculating |z|. When |x = 0| and |y = 0|.

18 days ago | 0

Answered

array indexing with repeated index, index size larger than the array

One way: A = {'a' 'b' 'c' 'd'}; I = [1 1 3 1 1 1 2 2 1]; B = A(I);

array indexing with repeated index, index size larger than the array

One way: A = {'a' 'b' 'c' 'd'}; I = [1 1 3 1 1 1 2 2 1]; B = A(I);

22 days ago | 0

| accepted

Answered

How do I solve the error "Improper assignment with rectangular empty matrix" caused by an error in the find command?

[~,C] = ismember(A,B);

How do I solve the error "Improper assignment with rectangular empty matrix" caused by an error in the find command?

[~,C] = ismember(A,B);

23 days ago | 1

| accepted

Answered

What is wrong with this code?

for ii = 1:8760 if v(ii)<vci || v(ii)>vco P(ii)=0; elseif vci<=v(ii) && v(ii)<vr P(ii)=(0....

What is wrong with this code?

for ii = 1:8760 if v(ii)<vci || v(ii)>vco P(ii)=0; elseif vci<=v(ii) && v(ii)<vr P(ii)=(0....

23 days ago | 0

| accepted

Answered

How do convert array x to array z?

or just: [~,~,z] = unique(x,'stable'); or more [~,z] = ismember(x,[4 8 5]);

How do convert array x to array z?

or just: [~,~,z] = unique(x,'stable'); or more [~,z] = ismember(x,[4 8 5]);

23 days ago | 0

Answered

how to take a matrix of certain values taken from the matrix

q = 125; [~,inx] = mink(abs(A(:,2) - q),2); B = A(inx,:); or for old MATLAB q = 125; [~,inx] = sort(abs(A(:,2) ...

how to take a matrix of certain values taken from the matrix

q = 125; [~,inx] = mink(abs(A(:,2) - q),2); B = A(inx,:); or for old MATLAB q = 125; [~,inx] = sort(abs(A(:,2) ...

28 days ago | 0

Answered

Get the max value and the indices of max value across a series of matrices

Let A - your cell array (25 x 50) with double matrix 128 x 128. n = size(A,1); maxvalue = cell(n,1); maxidx = cell(n,...

Get the max value and the indices of max value across a series of matrices

Let A - your cell array (25 x 50) with double matrix 128 x 128. n = size(A,1); maxvalue = cell(n,1); maxidx = cell(n,...

1 month ago | 1

| accepted

Answered

how to have a vector that counts how many repetitive numbers there is in another vector?

out = [(1:51)',histcounts(A,1:52)']

how to have a vector that counts how many repetitive numbers there is in another vector?

out = [(1:51)',histcounts(A,1:52)']

1 month ago | 0

Answered

how can i create 12 monthly maxima from a uniform distribution between 0 and 6? (using unifrnd)

R = unifrnd(a,b(end),[1,12]); or R = rand(1,12)*b(end);

how can i create 12 monthly maxima from a uniform distribution between 0 and 6? (using unifrnd)

R = unifrnd(a,b(end),[1,12]); or R = rand(1,12)*b(end);

3 months ago | 0

| accepted

Answered

Collapsing data that are within one integer value of each other

n = diff(z(:)) == 1; lo = [n;0] | [0;n]; nn = [diff([0;n]) == 1;0]; nn(~lo) = 1; out = ceil(accumarray(cumsum(nn),...

Collapsing data that are within one integer value of each other

n = diff(z(:)) == 1; lo = [n;0] | [0;n]; nn = [diff([0;n]) == 1;0]; nn(~lo) = 1; out = ceil(accumarray(cumsum(nn),...

3 months ago | 1

| accepted

Answered

How to merge adjacent NaN values into single NaN value in a vector?

a = [1 2 3 NaN NaN 0 1 2 NaN 9 8 7 6 NaN NaN NaN 1 1]; lo = ~isnan(a); lo(strfind(lo,[0 1])) = true; out = a(lo);

How to merge adjacent NaN values into single NaN value in a vector?

a = [1 2 3 NaN NaN 0 1 2 NaN 9 8 7 6 NaN NaN NaN 1 1]; lo = ~isnan(a); lo(strfind(lo,[0 1])) = true; out = a(lo);

3 months ago | 0

Answered

Sir, am having the four mat files, which of two contains features from minutie and other two contains feature from invarient moment, can i make fusion of those features by combining it then how?

V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')}; n = cellfun(@fieldnames,V,'un',0); V1 = cellfun...

Sir, am having the four mat files, which of two contains features from minutie and other two contains feature from invarient moment, can i make fusion of those features by combining it then how?

V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')}; n = cellfun(@fieldnames,V,'un',0); V1 = cellfun...

3 months ago | 0

Answered

Error in following code while converting cell to matrix

fusion = cell2mat(cat(1,out{:})); or just V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')}; ...

Error in following code while converting cell to matrix

fusion = cell2mat(cat(1,out{:})); or just V = {load('db1.mat'),load('db2.mat'),load('db3.mat'),load('db4.mat')}; ...

3 months ago | 0

Answered

How to create matrix from descending number of vector elements without loop?

A = [1 2 5 3 4]; n = numel(A); out = ones(n,1)*A.*flip(triu(ones(n)),2); or just ( |MATLAB >= R2016b|) out = A...

How to create matrix from descending number of vector elements without loop?

A = [1 2 5 3 4]; n = numel(A); out = ones(n,1)*A.*flip(triu(ones(n)),2); or just ( |MATLAB >= R2016b|) out = A...

3 months ago | 0

| accepted