Answered
Find all subset index of an array whose sums equal or nearest to a given target
a = dec2bin((0:bin2dec(sprintf('%d',ones(1,numel(array)))))')-'0'; k = bsxfun(@times,a,array); d = abs(sum(k,2) - 700); ...

10 years ago | 0

Answered
Finding rows with the closest values in two matrices matlab
[ma, na] = size(A); [ia,ja] = ndgrid(0:ma-1,0:na-1); F = griddedInterpolant(ia,ja,A); [mb, nb] = size(B); [ib,jb] ...

10 years ago | 0

Answered
Hermitian transpose of a vector with complex elements
out = A'; % A - your data

10 years ago | 1

| accepted

Answered
Computing mean by group (need help with speed!)
[~,~,c]=unique(id); [ii,jj] = ndgrid(c,1:size(Xw,2)); bb = accumarray([ii(:),jj(:)], Xw(:), [], @mean); out = Xw ...

10 years ago | 1

Answered
Need help creating a code
At = A(:,1) <= -2; B = sum(At); C = sum(At & abs(A(:,2))>=2);

11 years ago | 0

Answered
how to average hourly data set.
|your_array| - double array with size [180 x 360 x 3456] s = size(your_array); [ii,jj,k] = ndgrid(1:s(1),1:s(2),1:ceil((...

11 years ago | 0

Answered
sort a line of the matrix and change the other lines according the line sorted
[~,ii] = sort(a(1,:)); out = a(:,ii);

11 years ago | 0

Answered
How can I look up and interpolate a value from a set of 3D gridded data? I am given Y and Z dimensions, and need to find X.
F = griddedInterpolant({Y,flip(X)},flip(Z,2)); z = [3;2;1]; y = [0;8;3]; your_x = arrayfun(@(y,z)fzero(@(x)z - F(...

11 years ago | 0

| accepted

Answered
How to concatenate table columns into one columns
T = [randi([2014 2016],10,1),randi([1 12],10,1),randi([1 28],10,1)]; out = datestr(datenum(T),'mm/dd/yyyy');

11 years ago | 0

| accepted

Answered
How to split a cell array by finding certain cells
accumarray(cumsum(strcmp(testCell,'start'))',... (1:numel(testCell))',[],@(x){t...

11 years ago | 1

Answered
Matrix Multiplication column and vector
A is 1 column of 100k results; W is a vector of 10 weights; A(:)*W(:).'

11 years ago | 0

| accepted

Answered
The usage of find in matlab for finding the length of repeated element
a = unique(x(:)); out = [a,histcounts(x,[a,a(end)+1])']; for |v = [1, 1, 1, 2, 2, 1, 1, 7, 7, 4, 4, 4, 2]';| i0 = [...

11 years ago | 0

Answered
Averaging daily values from annual data
f = fopen('data.txt'); c = textscan(f,'%s %s %f'); fclose(f); [y m d] = datevec(datenum(strcat(c{1:2}),'dd:mm:yyy...

11 years ago | 0

Answered
Finding minimum value between certain rows
i0 = [true;diff(A(:,3))~=0]; ii = cumsum(i0); am = accumarray(ii,(1:numel(ii))',[],@(x){A(x(A(x,1)==min(A(x,1))),:)}); ...

11 years ago | 1

Answered
how to count non zero elements in a vector and replace this values based on the count values
v= [0 0 0 0.1 0.2 0.3 0.4 0.5 0 0 0 0 0 0 0.1 0.2]'; ii = v ~= 0; t = [false;diff(ii)==1]; i1 = cumsum(t).*ii; ...

11 years ago | 1

Answered
For loop or Array?
out = cumsum(circshift(A,[0,3]),2)>0; add m = 3 b = [zeros(size(A,1),1),diff(A,[],2)]==1; out = cumsum(b(:,[m+1:...

11 years ago | 1

Answered
Get the Array Number, when value changes
A = {1 'Monday' 2 'Monday' 3 'Monday' 4 'Sunday' 5 'Sunday' 6 'Friday' 7 'Friday' 8 'Friday'}; [a,...

11 years ago | 1

Answered
Monthly Average for Large Dataset
f = fopen('NG1_all_wav'); c = textscan(f,['%s',repmat(' %f',1,15)],'CollectOutput',1); fclose(f); [a,~,c1] = uniq...

11 years ago | 1

Answered
How can I count how many multi-dimension arrays in a matrix?
z = nnz(ismember(B,[1 2],'rows'));

11 years ago | 1

| accepted

Answered
vectorial programming instead of for-loops
hn = .5; n=size(MatrixX,2); f = ... sum(sqrt(sum((bsxfun(@minus,xMatrix,permute(MatrixX,[1,3,2]))/hn).^2)),3)/(n*(hn...

11 years ago | 0

| accepted

Answered
How to determine which indices in a row cell array contains the value 1, even when there are null vectors [ ] in the cell array?
C = {[], [], [], [], 1, 1, 1, 1, 1, 1, 4, 4, 5, 5, 5, [], [], []}; b = C; b(cellfun(@isempty,b))={nan}; d = find([b{:...

11 years ago | 0

Answered
How to access a structure array using a loop?
n = {'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' 'p9' 'p10'}'; d = {p1 p2 p3 p4 p5 p6 p7 p8 p9 p10}'; p = cell2struct(d,...

11 years ago | 2

Answered
matrix index (I tried to name a matrix to use in a loop like variables.)
A=[1 2;3 4]; jj=9; A = bsxfun(@times,A,2.^reshape(0:jj-1,1,1,[]));

11 years ago | 0

Answered
As I can compare rows in a column?
f = fopen('your_data.txt'); c = textscan(f,'%s','delimiter','\n'); fclose(f); c = c{:} z = regexp(c,'-?\d+(\.\...

11 years ago | 1

| accepted

Answered
How to find the day number of any year from a date?
x = [2012 1 2; 2012 3 3; 2013 3 3]; d = datenum(x); out = d - datenum(year(d),1,1) + 1;

11 years ago | 3

Answered
Counting unique values across the columns of a matrix
[~,ii] = mode(X); out = find(size(X,1) - ii >= 3);

11 years ago | 1

Answered
Find the index of nonempty array in a structure for a particular field
find(~cellfun(@isempty,{select.c}))

11 years ago | 3

| accepted

Answered
Error in interp2: The grid vectors do not define a grid of points that match the given values
x = 1:512; y = 1:721; nx = 512; ny = 721; ni = 1024; xi = linspace(1,nx,ni); yi = linspace(1,ny,ni); ...

11 years ago | 6

| accepted

Answered
how can get this numbers in to array and the text in another array
A={{1212 1.1261 1.1342 1.1396 1.1432 1.1481 1.1753 1.2072 1.2422 1.3233 1.3596 2.3762 1.4147 1.4152 1.4216 'Public_Health_and_...

11 years ago | 1

Load more