Answered
Extend a matrix by extending its vectors
B = A(kron((1:d)',ones(d,1)),:,:);

12 years ago | 1

| accepted

Answered
Replacing the column of array elements with NaN.
Out_Arr = A; Out_Arr(all(bsxfun(@lt,A(:,1),x(:,1)')|bsxfun(@gt,A(:,1),x(:,2)'),2),2) = nan;

12 years ago | 1

Answered
delete same number every two number while keeping the original order
x = [true(size(B,1),1), diff(B,1,2)~=0]'; ii = sort(x,'descend'); Bt = B'; z = nan(size(x)); z(ii) = Bt(x); out...

12 years ago | 0

Answered
How to store the output of a loop in a matrix/vector when the loop is not indexed?
a=-1; b=-1; p=-0.5; a1 = a./sqrt(2*(1-p^2)); b1 = b./sqrt(2*(1-p^2)); x = [0.10024215,0.48281397,1.0609498,1.77...

12 years ago | 0

| accepted

Answered
How to count frequency of values in a 3D array
out = histc(reshape(yourdata,[],size(yourdata,3)),1:8);

12 years ago | 0

Answered
detect consecutive duplicates in a structure
H = squeeze(struct2cell(A)); [~,~,c] = unique(reshape([H{:}],size(H))); ttest = histc(c,unique(c));

12 years ago | 0

Solved


Calendar Matrix
Return a calendar matrix for the given values of month and year. Assume that Sunday is the first day of the week. The resulting ...

12 years ago

Answered
HOW TO ACCESS THE FOLLOWING ELEMENTS FROM THE GIVEN ARRAY
A1 = reshape(permute(reshape(a(1:end-1,:),2,2,[]),[1,3,2]),[],2); a02 = [a(:,2:end-1);a(2:end,end)']; A2 = reshape(p...

12 years ago | 1

Answered
Please help: calculate average frequency of histogram
Sp=[3 9 1 2 3 2.5 7.8 6.5 9.3 9.1]'; [n,b] = histc(Sp,0:2:10); c = accumarray(b,(1:numel(Sp))',[],@(x){x}); ii = ...

12 years ago | 1

| accepted

Answered
cell to double problem for loop includes cellarrays.
xc = mat2cell(A,B,size(A,2)); yc = mat2cell(C,B,size(C,2)); out = cellfun(@(a,b)(a'*a)\a'*b,xc,yc,'un',0);

12 years ago | 0

Answered
How to generate an array alternating the values of two others?
out0 = [A(rem(0:numel(B)-1,numel(A))+1);B]; out = out0(:)';

12 years ago | 0

Answered
How to find where the differences between elements is constant?
xy = [0 29 0 30 0 30 16760 30 16760 31 16760 31 16760 31 16760 31 16760 31 16760 32 ...

12 years ago | 1

| accepted

Answered
how remove duplicate rows ?
C = setdiff(A,B,'rows','stable')

12 years ago | 0

Answered
easy question- matrix divide
out = mat2cell(A,10*ones(30,1),size(A,2))

12 years ago | 0

| accepted

Answered
Assigning a variable for matrices
S = eval(strcat('{',sprintf('S%d;',1:39),'}')); Sn = cat(3,S{:}); ii = [31 28 31 30 31 30 31 31 ...

12 years ago | 0

Answered
a problem with for loop and indexinf
A = eval(strcat('{',sprintf('Array_%d;',1:10),'}')); AR = cellfun(@(x)exp(x)+x.^2,A,'un',0);

12 years ago | 0

Answered
How to find string value?
out = regexp(A,'\w{2}\d{1}','match')

12 years ago | 0

| accepted

Answered
Vectorization of for/loop
laminate.ply = struct('angles',num2cell(angles(:)/180*pi),... 't',num2cell(thickness(:)),... ...

12 years ago | 0

| accepted

Answered
More efficient way of this code?
fun1 = @(v,n)repmat(v,1,n)

12 years ago | 1

| accepted

Answered
I need help in (Position in matrix)
find(T==5)

12 years ago | 0

Answered
determine the loop which satisfies the particular condition.
x = mat2cell(A,B,size(A,2))

12 years ago | 1

Answered
How can I find matching rows from three out of four colomns
d = [1 2 3 4 2 4 6 8 1 2 3 5]; [a,b,c] = unique(d(:,1:end-1),'rows'); out = [a, accumarray(c,d(:,end))]; *_...

12 years ago | 0

Answered
How to vectorize this code with logical idexing
a=[10:5:50]; b=[10:20:50]; c=rand(size(a)); [~,ii] = histc(a,b); d = accumarray(ii(:),c(:),size(b(:)),@(x){x})...

12 years ago | 0

| accepted

Answered
for loop to control cellarray whether it is changing or not.
[a,~,c] = unique(ids); out = [strcat('a_',a),num2cell(accumarray(c,data))];

12 years ago | 1

| accepted

Answered
how to append values in a vector in for loop?
out=[0 1;1 3;2 5;3 5; 7 2; 8 1;9 1;11 4]; k = 0; for i=1:8 if out(i,2)==max(out(:,2)) k = k + 1; ...

12 years ago | 1

| accepted

Answered
How do I combine vectors to form a matrix?
combined = cell2mat(cellfun(@(x)x(:,5),mydata,'un',0));

12 years ago | 0

| accepted

Answered
How to reorder the rows by sorting the elements of column in ascending order?
[~,ii] = sort(id); id_out = bsxfun(@(a,b)a(b,:),id,permute(ii,[1 3 2]));

12 years ago | 0

Answered
Repeative selecting unique values of matrix
M = [2 3 8 1 4 7 6 5 9 1 3 8 9 4 6 5 2 7 2 8 1 4 6 3 9 5 7]; ii = ndgrid(1:size(M,1),1:size(M,2)); [...

12 years ago | 0

Load more