Answered
Problems repeating matrix in desired order
A(:,:,1) = [1 2; 3 4]; A(:,:,2) = [5 6; 7 8]; B = permute(repmat(A,1,1,1,2),[1 2 4 3]);

9 years ago | 0

Answered
Reading large data set from text file & separating to individual column
T = readtable('doc.txt') [a,b,c,d] = datevec(datetime(strcat(T{:,1},{' '},T{:,2}),'I','yyyy/MM/dd HH:mm:ss')); out = [a,...

9 years ago | 0

Answered
group an array according a condition
B_table = varfun(@max,array2table(A),'GroupingVariables','A1') or B = splitapply(@(x)max(x,[],1),A,findgroups(A(:,1)))...

9 years ago | 2

| accepted

Answered
Averaging sequential data if values are the same?
key_column_avg = key_column(diff([0,key_column(:)'],1,2) ~= 0);

9 years ago | 0

| accepted

Answered
How can i compute the mean of specific number of table rows?
n = 278984; t = minutes(10*(1:n)'); D = randi(255,n,2); % Let D - your data (278984 x 2) TT = timetable(t,D(:,1),...

9 years ago | 0

Answered
How do you delete text data from a row if its characters are equal to or less than 3
a = string({'Trinidad & Tobago' 'USD' 'Turkey' 'TRY' 'USD' 'Uganda' 'UGX' 'Ukraine' 'USD' 'United A...

9 years ago | 0

Answered
Creating a diagonal matrix
full(spdiags(ones(4,3),0:2,4,6)) or t = true(4,6); out = tril(t,2) & triu(t) or a = triu(ones(4,3)); out...

9 years ago | 0

Answered
How to vectorize integral?
h=0.1; t1=0:h:2*pi; p = arrayfun(@(t)integral(@(s)(t-s).^-alpha.*cos(s),0,t),t1)

9 years ago | 0

Answered
Creating a diagonal matrix
t = true(2,4); out = tril(t,2) & triu(t);

9 years ago | 0

Answered
Optimise for loop in using cell array
lengthboundaries = cellfun(@length,boundaries);

9 years ago | 1

| accepted

Answered
how to vectorize these "for loop"?
My "ruble". [b,a,k] = ndgrid(1:.5:10); n = numel(k); num1 = [k(:),k(:).*a(:)]; den1 = [ones(n,1), b(:), zeros(n,1)...

9 years ago | 1

| accepted

Answered
How to iterate through matrix with rows and columns changing by the same value?
B = max(A)'; or B = zeros(size(A,2),1); for col=1:size(A,2) B(col,1)=max(A(:,col)); end

9 years ago | 3

| accepted

Answered
Merging two dissimilar matrix based on common row element
A = [1 2.576 1 2.822 13 2.679 13 2.786 25 2.653 25 2.596 25 2.565]; B = [kron((1:25)',[1;1;1]...

9 years ago | 1

Answered
3d Mesh Volume Calculation
If your data (let A) is 2d array: V = trapz(trapz(A,2));

9 years ago | 0

Answered
how to vectorize these "for loop" ?
[c,b,a,k] = ndgrid(1:10); nump = [k(:), a(:).*k(:)]; denmp = [ones(numel(k),1), b(:)+c(:), b(:).*c(:)];

9 years ago | 2

Answered
Synchronize time series (fints) error
T1 = readtable('cem19_price-history-07-23-2017.csv', 'DatetimeType','text'); T2 = readtable('cem19_price-history-07-23-2017...

9 years ago | 0

| accepted

Answered
How to organise cell array data into a single table
N = ["X";"Y"] + string(1:numel(coordinates)); k = N(:)'; k = [{'T'},{k{:}}]; n = cellfun('size',coordinates,1); [m...

9 years ago | 0

Answered
Applying a Moving average function smooth
Let A - your data (N x 72); out = conv2(A,ones(5,1)/5,'valid');

9 years ago | 1

Answered
Extract or keep rows based on an array.
A = {1 'cat' 24; 1 'dog' 2; 2 'horse' 10; 2 'dog' 3; 3 'sheep' 45; 3 'cow' 203; 4 'cow' 233; 5 'pig' 23; 5 'walrus' 2; 6 'hors...

9 years ago | 0

Answered
How can I concatenate two string vectors 5x1 and 1x18 to get a 5x18 text matrix
*In R2016b:* >> Currencies = {'ARS','BRL','CLP','COP','CZK','HUF','IDR','MXN','MYR','PEN','PHP','PLN','RON','RUB','ZAR','TH...

9 years ago | 0

Answered
How do you decide whether to use a matrix or vector of structures?
T = readtable('20170731.xls') out = sum(prod(T{1:2,~cellfun(@isempty,regexp(T.Properties.VariableNames,'A'))}));

9 years ago | 0

Answered
How to compare non latin letters?
>> %cyrillic >> 'АБВГДЖЗ' - '0' ans = 992 993 994 995 996 998 999 >> isletter('Ж') ans = lo...

9 years ago | 1

| accepted

Answered
How can I generate a random matrix with 0's and 1's?
[~,ii] = sort(rand(m,n)); out = ii <= d;

9 years ago | 1

Answered
Optimize my for loop with vectors
kx = -1:dk:1; [xx,yy] = ndgrid(0:dk:1,kx); t = xx <= sqrt(1-kx.^2); m = [xx(:),yy(:)]; a = m(t(:),:).^2; out = ...

9 years ago | 0

| accepted

Answered
Multiply each column in MxN matrix with it's transpose to create MxMxN matrix
Let |A| - your matrix [M x N] out = bsxfun(@times,permute(A,[1,3,2]),permute(A,[3,1,2]));

9 years ago | 0

Answered
Averaging sections of a vector
z = A; z(z == -999) = nan; t = ~isnan(z); B = accumarray(cumsum(diff([~t(1);t(:)]) ~= 0),z,[],@mean);

9 years ago | 0

Answered
How to find a submatrix index for non equal dimensioned vectors ?
ii = strfind(k1,k2); try out = ii + (0:numel(k2)-1); catch out = []; end or n = numel(k2); l...

9 years ago | 0

Answered
Remove rows from cell Array which have string in the first column
M={'test' '12' '122' '...' 'test2' '123' '234' [] '1234' 'RR' '123' [] 'test4' '123' '234' [] ...

9 years ago | 0

Load more