Answered
diagonal pixel differences of image matrix
b = [2 1 8 24;9 10 3 12;2 5 8 19;1 2 3 4]; out = rot90(spdiags(tril(triu(flipud(diff(flipud(spdiags(b,-2:2))))),2))); ...

13 years ago | 1

| accepted

Answered
How can i calculate the largest interval when the elements of an array are larger than a value?
x = [ 0 6 5 2 16 17 16 11 12 14 5 6 9 16 17 18 18 9]; xx = x(:) > 15; t = cumsum([false;diff(xx) == 1]); z = acc...

13 years ago | 0

Answered
Find indexes of strings that have special characters.
a = {'someString';'String';'otherString';'someString';'String'}; out = find(~cellfun('isempty',regexpi(a,'some|other'))...

13 years ago | 0

| accepted

Answered
How to delete rows from the bottom of matrix
out = A(flipud(cumsum(flipud(all(A,2)))>0),:);

13 years ago | 0

| accepted

Answered
How to create variables using strings in an array?
str1={'x','trs','height','width'} str2='db_xtr' input1 = [strcat(str1,'_',str2);num2cell((1:numel(str1)).^2+2)] C = s...

13 years ago | 1

Answered
how to generate binary matrix with all combination having equal probability of 1 and 0 ?
use Roger Stafford's <http://www.mathworks.com/matlabcentral/answers/76363-changing-position-of-numbers-in-a-vector idea> ...

13 years ago | 1

Answered
need syntax to store and preallocate the output from a for loop and use them for serial multiplication
Zo = 100; H = (1.0000 + 0.0000i); N = (0.0000 + 0.0029i); Ds = (2.1132e+004 +6.1764e+001i); ZB = reshape(1:2:20,1...

13 years ago | 0

| accepted

Answered
maximum value in a 3d matrix
s = size(A); [v,ii] = max(reshape(A,[],s(3))); [i1 j1 ] = ind2sub(s(1:2),ii); out = [v;i1;j1;1:s(3)]';

13 years ago | 1

Answered
Syntax to multiply 10 different 2 by 2 matrices sequentially in matlab
A = cat(3,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10); s = size(A,3); out = A(:,:,1); for jj = 2:s out = out*A(:,:,jj); ...

13 years ago | 1

| accepted

Answered
Distance between elements of matrix
out = abs(bsxfun(@minus,U,U')); or use function <http://www.mathworks.com/help/nnet/ref/dist.html |dist|> from Neural Netwo...

13 years ago | 1

| accepted

Answered
Attempted to access a(2); index out of bounds because numel(a)=1
a = '111100011'; indi = regexp(a,'0+|1+','match')

13 years ago | 0

| accepted

Answered
input a string into a vector when n=odd number
n = 20; x=(0:n)'; xcell=num2cell(x); xcell(rem(x,2) == 1) = {'jamp'};

13 years ago | 0

Answered
multiply lines of a matrix by a line
try <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|>: C = bsxfun(@times,A,b);

13 years ago | 1

Answered
expanding the existing matrix
kron(M,ones(3,2)) or m = 3; n= 2; s = size(M); out = reshape(permute(reshape(repmat(M,m,n),s(1),m,s(2),n),[2 ...

13 years ago | 0

| accepted

Solved


Binary
Given a positive, integer n, create a function that returns the respective binary number in the form of a vector. Example: ...

13 years ago

Solved


Create a matrix with difference of each row of input matrix
With a given input matrix A, create a output matrix B in such a way that each row in B is a difference of rows of input matrix A...

13 years ago

Answered
Replacing values for matrices of different dimension
[a,ia0] = sort(A(:,2)); ba = histc(a,unique(a)); t1 = [true;diff(B(:,1))~=0] + 0; t1(find(t1) + ba)= -1; t3 = cums...

13 years ago | 1

| accepted

Answered
~ismember does not work on my matrix
Try C = setdiff(B,A(:,2:end),'rows') or C = B(~ismember(B,A(:,2:end),'rows'),:)

13 years ago | 1

| accepted

Answered
How to remove Nans from matrix
out = resM(M==M) ADD M1 = M'; out = reshape(M1(M1==M1),size(M,2),[])';

13 years ago | 0

Answered
subsetting elements in one matrix by those in a smaller vector
p = [10;11;14;16;20;24;29;30]; [l,ii]=ismember(X(:,3),p); i2 = sort(ii); x1 = X(l,:); out = mat2cell(x1(i2,:),hist...

13 years ago | 1

Answered
add new columns to the existing matrix
a - your array < 64 x 63 double > out = [a zeros(size(a,1),1)]; or a(64,64) = 0;

13 years ago | 3

Answered
Calculate differences through an array, by means of local absolute references inside of a matrix. And saving results.
m = dlmread('path_your_out.txt'); t=[true;diff(m(:,1)) < 0]; out = m-n(cumsum(t),:); out = out(any(out,2),:); or ...

13 years ago | 0

| accepted

Answered
re arrange/shape matrix according to the position of a index value in array.
z=[306.000 305.952 304.683 302.265 300.219 306.000 306.008 304.977 302.450 299.846 306.000 305.962 304.840 302.413 299.8...

13 years ago | 0

Answered
How to calculate the sum of values in column 2 if column 1 has a certain value?
a - your array < 10000 x 2 double > [a1,ii,ii] = unique(a(:,1)); out = [a1,accumarray(ii,a(:,2))];

13 years ago | 0

Answered
How to convert convert a cell{x,y,...}(V,W) into an array(x,y,...,V,W) with an "automatic process" ?
z = cellfun(@(x)randi(26,2,9),cell(3,7,4),'un',0); % Let it be your array nc = size(z); nm = size(z{1}); sznew = ...

13 years ago | 0

| accepted

Answered
How to merge similar matrixes and list them on columns.
Umn = [Latitude(:) Longitude(:) U(:)]; other variant M = cat(3,Latitude,Longitude,U); C = cellfun(@(x)x(:)',num2cel...

13 years ago | 1

| accepted

Answered
to find position of min value
A - your array; [v1,ii] = min(A); [v2,jj] = min(v1); out = [v2,ii(jj),jj]; or [v3,ij] = min(A(:)); [i1,j1]...

13 years ago | 1

| accepted

Answered
re arrange shape matrix according to the position of a index value in array.
x = dlmread('x.txt'); out = permute(reshape(x,[],numel(unique(x(:,1))),size(x,2)),[2 3 1]); ADD s = size(x); n =...

13 years ago | 0

Answered
Returning peak values from a column
t = [true;diff(Cp(:))>=0] Cf_new = Cf(t); Cf_new2 = Cf(~t);

13 years ago | 0

Answered
Removing rows from a column depending on another column
out = Cf(1:find(Cp>=.99,1,'first'));

13 years ago | 0

Load more