Answered
Using vectors as the start and end of indices
a = 1:50; out = a(any(bsxfun(@ge,a(:)',start(:)) & bsxfun(@le,a(:)',finish(:))));

10 years ago | 2

Answered
sum of a matrix of monomials
sum(A,2); % A - your 'matrix of monomials'

10 years ago | 0

Answered
using if condition for swapping rows of a matrix
out = A(seq,:);

10 years ago | 0

| accepted

Answered
How could I use a loop in this case?
[~,~,c] = unique(A(:,11)); z = accumarray(c,A(:,7),[],@max); out =[A,z(c) - A(:,7)];

10 years ago | 2

Answered
Extract date and time information and calculate time interval
fileID = fopen('20160613.txt'); c = textscan(fileID, '%s %s %s %s %f %s %f','delimiter',';'); fclose(fileID); out...

10 years ago | 0

Answered
how can I add a condensed column vector of hour and minutes into my datetime variable
a=[1 2 3 59 100 101 2259 2300] b = a/100; out = [fix(b), 100*rem(b,1)]

10 years ago | 0

| accepted

Answered
How can I add leading zeros in a column vector?
sprintf(['%0',sprintf('%d',max(ceil(log10(X)))),'d\n'],X)

10 years ago | 1

Answered
How can I delete the continuously duplicated value and keep the last one in a cell array?
f = fopen('20160609.txt'); c = textscan(f,'%s %s %s %f','delimiter',','); fclose(f); t =[diff(c{end})~=0;true]; C ...

10 years ago | 0

| accepted

Answered
How to split strings lines to Matrix columns?
k=['100010001000'; '100000000000']; out = k -'0'

10 years ago | 0

Answered
Eliminate a row where a column has repeated values
[~,b] = unique(eliti(:,18),'stable'); eliti_new = eliti(b,:);

10 years ago | 0

| accepted

Answered
how to use regexp for negative and positive integers?
a = {'204' '203' '191' '133' '63' '-28' '-109' '-145' '-196' '...

10 years ago | 2

| accepted

Answered
Binned data question - average and median
z = [100 0.0276 0.1012 101 0.0279 0.1012 102 0.0278 0.1017 103 0.0334 0.102 104 0.0289 0.1024 105 0.0346 0.1014...

10 years ago | 0

| accepted

Answered
x=[x1(:,:) x1(:,:)] ?
>> x1 =[ 1 2 3 4]; x = [x1(:,:), x1(:,:)] x = 1 2 1 2 3 4 3 4

10 years ago | 0

| accepted

Answered
How to modify this code for combining matrices
[m,n] = size(A); Y1 = reshape(permute(cat(3,A,circshift(A,[0 -1])),[3,2,1]),2,[]); % Y2 = flip(Y1,1); Bp = permute(B...

10 years ago | 1

| accepted

Answered
How to calculate max. matrix row number
m = size(A,2); Y1 = reshape(permute(cat(3,A,circshift(A,[0 -1])),[3,2,1]),size(A,1),[]); % Y2 = flip(Y1,1); Bp = per...

10 years ago | 1

| accepted

Answered
How can I adjust my numbers
out = (yourarray - min1)/(max1-min1)*255

10 years ago | 0

| accepted

Answered
Combine different matrices to create a new one
A= [4 1 6] B= [4 1 6 8 1 6 1 4 6 1 6 4 4 6] K = permute(hankel(A(1:2),[A(2:end),A(1)]),[3,1,...

10 years ago | 1

| accepted

Answered
How can I get coordinates of number in a matrix?
a =[0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]; [y,x] = find(a)

10 years ago | 0

| accepted

Answered
How to count occurences of an element in a cell
a = {184 37843 850 1 184 37843 850 1 184 37843 850 1 184 37843 ...

10 years ago | 2

Answered
find N number of min values
s = [10 11 1 5 6 3 23 4 1 3 98 56]; [a,b] = un...

10 years ago | 1

Answered
Creating more than one matrix from 1 matrix
[m,n] = size(yourmatrix); % k - number rows in new array(s) % if rem(m,k) ~= 0 out1 = mat2cell(A,accu...

10 years ago | 0

Answered
How to count iterations of an element in a column according to elements in another column?
d = unique(hh(:,2)); a = ismember(hh(:,3),1:2); b = ismember(hh(:,3),4:5); step1 = sum(a + b); step2 = [d, accumar...

10 years ago | 1

| accepted

Answered
create a struct based on user id
[a,~,b] = unique(LocationRecords(:,1)); x = cellfun(@(x)sprintf('id_%d',x),num2cell(a),'un',0); y = accumarray(b,(1:nume...

10 years ago | 1

| accepted

Answered
how to make hourly, daily monthly rainfall in matlab?
data = xlsread('rain.xlsx'); [y,mm,d,h,m] = datevec(data(:,1) + datenum([1900 0 0]) - 1); cum_minutes = [y,mm,d,h,m, cum...

10 years ago | 1

| accepted

Answered
Matrix indexing using a vector
C = accumarray([(1:numel(b))' b],1)

10 years ago | 1

Answered
How to find out numbered value in a matrix
Anew = A(~cellfun(@isempty,A))

10 years ago | 1

| accepted

Answered
Common pairs from all rows except first row (vector) and how many times....
A = {A1,A2,A3,A4}; C = cellfun(@(x) hankel(x(1:end-1),x(end-1:end)),A,'un',0); [a,~,c] = unique(cat(1,C{:}),'rows'); ...

10 years ago | 2

| accepted

Load more