Answered
sum and average of a vector
z = accumarray(ceil((1:numel(A))'/3),A(:),[],@mean);

10 years ago | 0

Answered
How to find a certain content with index in cell array by looping
B = A'; out = cat(1,B{:});

10 years ago | 1

Answered
How can I use: DateString/datevac for a long year dataset? Dates from 01/01/1988 to 05/03/2005?
bed variant (Now I do not have access to MATLAB and use the Octave): f = fopen('FB_DSAT_1988to2005with year_USE.txt'); ...

10 years ago | 0

| accepted

Answered
Efficient method for populating a matrix based on its equality with another matrix
[lo,ii] = ismember(A(:,1:2),B(:,1:2),'rows'); B(ii(lo),:) = A(lo,:); or lo = all(A(:,1:2) == B(:,1:2),2); B(lo,:...

10 years ago | 1

| accepted

Answered
How to get results from symbolic variable integration
in R2016a >> syms x b4 = (x^127+x^32-x^12+78*x^2-5*cos(x)); int(b4, 0, 1) ans = 1425581/54912 - 5*sin(1) >> ...

10 years ago | 0

Answered
How to eliminate for-loop?
A = [1 2; 3 4]; B = [5 6 7; 8 9 10; 11 12 13]; C = [1 0 0; 0 2 0; 0 0 0]; n = size(A,2); Cd = diag(C); D = ...

10 years ago | 1

| accepted

Answered
How to make sure that if creating a diagonal matrix from another, the matrices are the same size?
b = full(spdiags(diag(a,1),1,size(a,1),size(a,2))); or b = diag(diag(a,1),1); b = b(1:size(a,1),1:size(a,2)); or...

10 years ago | 1

Answered
Using symbolic matrix operations correctly?
reshape(jacobian(trace(A.*X),X(:)),size(A))

10 years ago | 1

Answered
how to convert a given matrix in an array while reading all the elements of matrix in a particular order.
Variant by Azzi with the small addition: A = randi([-6 6],4,6); ii = reshape(1:numel(A),size(A)); z = spdiag...

10 years ago | 0

Answered
Finding weekly and yearly averages
solution without |datetime| and |table|: d = xlsread('2016_07_11_StrTempSCC.xlsx',1,'A4:Z16749'); T = d(:,2:end); T(T...

10 years ago | 1

Answered
How to plot cost curve with conditions
y = cumsum((x <= 5 & x > 0)*10 + (x > 5)*5)

10 years ago | 1

| accepted

Answered
Directly using Index of max value without storing
out = Y(max(X)==X)

10 years ago | 0

Answered
How to set a polynomial as a variable
B = zeros(24,3); B(sub2ind(size(B),[22,24,19,24,1,24],[1,1,2,2,3,3])) = [1,1,1,4,1,-45]; ii = bsxfun(@power,reshape(1:10...

10 years ago | 0

Answered
How to create comparison matrices "comparing" arrays from an struct array with 4 columns and N rows?
sArray (1) .array1 = { '1' '1' '1'} sArray (1) .array2 = { '1' '1' '3'} sArray (1) .array3 = { '1' '1' '1'} sArray (1...

10 years ago | 0

| accepted

Answered
Pad a vector to get matrix
A = 5:-1:0; n = numel(A); B = zeros(2*n-1); B(n,n) = 1; B = A(bwdist(B,'chessboard') + 1) or without |Image...

10 years ago | 1

Answered
Standardisation about zero mean
a = randi(20,8,6); out = bsxfun(@minus,a,mean(a));

10 years ago | 1

Answered
How to remove repeating pair
without 'stable' A={'HT0MEK1' 'H0MEK1' 'HT0MEK2' '78 T0MEK2' 'JT0KEL3' 'JKEL3_ul' 'JT0KEL4' '12 0KEL4_45' 'T0KEL5' 'P...

10 years ago | 1

| accepted

Answered
How to create a multidimensional matrix from a cell array where the cell array sizes are not he same?
EDIT n = cellfun(@numel,C); nmx = max(n(:)); K = cellfun(@(x,y)[cat(1,x{:});zeros(nmx-y,3)],C,num2cell(n),'un',0); ...

10 years ago | 0

| accepted

Answered
randomly select different elements of a vector
x=[1 1 1 2 3 4 4 4 5 6 7 7]; a = unique(x); out = a(randperm(numel(a),4))

10 years ago | 0

Answered
Find minimum value in every nth rows
a = CP15OND_SZA(2:end,4); a(cellfun(@isempty,a)) = {nan}; a = [a{:}]'; [aout,ii]= min(reshape(a,24,[])); C = CP15O...

10 years ago | 0

| accepted

Answered
Fill vector with missing values
yyear = [Year,Month,Day]; y1 = datevec(datenum([Year(1) 1 1]):datenum([Year(1) 12 31])); y1 = y1(:,1:3); missing_valu...

10 years ago | 0

| accepted

Answered
How to write own standard deviation function.
n = numel(R); yourstd = sqrt(sum((R(:) - sum(R(:))/n).^2)/(n - 1));

10 years ago | 0

Answered
How to concatenate (take cross product of) two datetime arrays?
Date = [datenum(2016,4,5), datenum(2016,5,4), datenum(2016,6,7)]; a = bsxfun(@plus,Date,1/48*(0:3)'); out = datestr(...

10 years ago | 0

Answered
How to use a formula for all elements of matrix?
M=[NaN 2.5000 0 2.5000 NaN -0.8333 0 -0.8333 NaN]; phi=@(m1,m2)atand(abs(...

10 years ago | 2

Answered
How to prevent cell array within cell array
record = {'school', 'class', name{:}}

10 years ago | 0

Answered
extract submatrix from a large matrix using loop
A=rand(1140,330); out = permute(reshape(A',size(A,2),60,[]),[2,1,3]);

10 years ago | 0

Answered
Combine cell array with contant matrices
A1 = cat,3(A{:}); A2 = zeros(size(A1)+[2,2,0]); A2(2:end-1,2:end-1,:) = A1; A_ = reshape(num2cell(A2,[1,2]),[],1);

10 years ago | 0

Answered
How do I concatenate cells in each row in a matrix?
num2cell(a,2)

10 years ago | 1

Answered
Create an array that has ones
num2cell(permute(repmat(eye(256),1,1,41),[1,3,2]),[1,2]) or num2cell(bsxfun(@eq,(1:256)'*ones(1,41),reshape(1:256,...

10 years ago | 2

Answered
concatenate vertically along the 3rd dimension of a matrix
reshape(permute(A,[2,1,3]),size(A,2),[])'

10 years ago | 3

Load more