Answered
Best way to filter a Matrix
my variant pf = [po(1)-1 po po(end)+1]; p = median(pf(bsxfun(@plus,1:3,(0:length(pf)-3)')),2);

15 years ago | 0

Answered
avoding loops by vectorization
outer_x = bsxfun(@plus,d_del(1,:)'*cos(t),x_i');

15 years ago | 1

Answered
finding region
so in <http://www.mathworks.com/matlabcentral/answers/10396-finding-interior-or-exterior-points> BW2 = bwmorph(I,'diag'); L...

15 years ago | 0

| accepted

Answered
graph path
<http://www.mathworks.com/matlabcentral/fileexchange/4266-grtheory-graph-theory-toolbox>

15 years ago | 0

Answered
best way to search date in vector
dev = datevec(dateinput); dateout = sortrows(dev(dev(:,2)==12,1:3),1)

15 years ago | 0

| accepted

Answered
selecting certain values from a list
[a b c]=unique(floor(A/100)); out = A(b)

15 years ago | 0

Answered
finding interior or exterior points
Have matrix I = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

15 years ago | 0

| accepted

Answered
using randn within an interval
v1 = randn(m,n); rndn12=1+(v1-min(v1(:)))/(max(v1(:))-min(v1(:))) *EDIT* (06/27/2011 22:58 MSK) itl = [-1 4]; % interval...

15 years ago | 0

Answered
finding endpoints of a label
L = bwlabel(I) I2 = bwmorph(I,'endpoints') epout = arrayfun(@(i1)find(I2 & L == i1)',1:max(L(:)),'un',0) *_example_*: ...

15 years ago | 0

Answered
finding neighbor of a position
idl = 6; idxs = ... nonzeros(bsxfun(@plus,idl - [1 0 -1]',size(I,1)*[-1 0 1]).*[1 1 1;1 0 1;1 1 1]) *CORRECTED* 06/27/2011...

15 years ago | 0

Answered
filling regions of matrix
Iout = bwlabel(~cumsum(I,2))+1

15 years ago | 1

| accepted

Answered
'reshape' by identifiers
L = M(:,2)==1; M2 = M(~L,:); M2(ismember(M2(:,1),M(L,1)),2) = M(L,3)

15 years ago | 0

Answered
plot of differernt regions of specific area in a matrix
Hi Hassan! Try this code: L = bwlabel(m2 == 2); lns = 1:max(L(:)); ln = regionprops(L, 'Area'); pm1 = find(ismembe...

15 years ago | 0

| accepted

Answered
How to convert row and column vectors of a symmetric matrix to zero if diagonal value is zero?
dg = diag(your_matrix); your_matrix(dg*dg'==0)=0 dg = diag(your_matrix); l1 = dg == 0; your_matrix(diag(l1)==1) = ran...

15 years ago | 3

Answered
randomly selection
1. randi(1e4) 2. variant X = randi(1e4,1,1e4); % rendom index (idx) of vector X, length of vector Xout - 300 idx = r...

15 years ago | 0

Answered
Writing elegant MATLAB code
1. My variant - is worse than variant of Titus Edelhofer reshape(sum(bsxfun(@times,reshape(rgb,[],3),permute(M,[3 2 1])),2),...

15 years ago | 0

Answered
Comma separated list generation
xc = repmat({X},1,3) Y = blkdiag(xc{:})

15 years ago | 0

| accepted

Answered
Finding a minumum range of sequential values
x = B == 1; idx1int = [strfind([0 x],[0 1]); strfind(x,[1 0])]; idxout = idx1int(:,diff(idx1int,1)+1>=5); nout = diff(id...

15 years ago | 0

Answered
plot of differernt regions in a matrix
m1 = rand(100,200); m2 = zeros(size(m1)); m2(1:3,4:7)=2; m2(10:12,150:160)=2; m2(1:3,8)=3; m2(80:90,150:160)=3; L ...

15 years ago | 1

| accepted

Answered
How to find a chunk of a certain number of zeros inside a vector
EDIT A1 = A(:)'; out = strfind([1 A1],[1 0])-1; % all groups zeros strfind([A1 1],[0 0 1]); % all groups two zeros .....

15 years ago | 0

Answered
finding interior region
>> [B,L] = bwboundaries(I,8,'noholes') B = [19x2 double] [ 7x2 double] L = 0 1 1 1 1 ...

15 years ago | 0

| accepted

Answered
region properties problem
regionprops(I,I,'PixelValues')

15 years ago | 0

Answered
close loop
B = bwboundaries(I,8,'noholes')

15 years ago | 0

| accepted

Answered
display problem
Iout = I; Iout(repmat(logical(I1),[1,1,3]))=0; imshow(Iout) corrected Iout = I; Iout(~repmat(logical(I1),[1,1,3]))=0...

15 years ago | 0

| accepted

Answered
Missing NaN functions?
so nansum Xnan20 = X; Xnan20(isnan(X))=0; out = sum(Xnan20);

15 years ago | 0

Answered
findding neares label
so D = bwdist(I) P1 = sum(D(logical(I1))) P2 = sum(D(logical(I2))) if P1 < P2 , disp('I1 is closer to the 1s in I ...

15 years ago | 0

| accepted

Answered
Joining label
C = nchoosek(1:max(L(:)),2); [ii jj c] = arrayfun(@(i1)find(bwdist(L==C(i1,1)).*(L==C(i1,2))),1:size(C,1),'un',0); leq = C...

15 years ago | 0

Answered
Extracting fields from structure arrays
[coeff(:).GARCH]

15 years ago | 6

| accepted

Answered
Finding values in a matrix for a given range
example: >> k = randi(35,7) k = 6 33 24 2 34 18 23 34 28 27 10 2 16 ...

15 years ago | 0

Answered
Date(class:cell) type problem
cellfun(@(c)datestr(c,'yyyymmdd'),cellarraydate,'un',0)

15 years ago | 2

Load more