Answered
How to find days that are togheter
t0 = temp(:)' >= 25; tt = [strfind([0,t0],[0 1]);strfind([t0,0],[1 0])]; out = cellfun(@(x)Data(x(1):x(2),:),num2cell(tt...

12 years ago | 0

Answered
Grouping continuous nonzero in a row vector
A = [0,0,0,0,3,2,5,2,4,1,5,0,1,2,5,0,0,0,0,0,0,0,0,0,1,1,2,6,3,1]; ii = zeros(size(A)); jj = A > 0; ii(strfind([0,jj(...

12 years ago | 1

Answered
problem with the symbolic calculation
q = [30;20;10]; S = sind(q); A = [S(1) S(2) 1;2 3 S(2);3 S(1) S(3)]; B=[S(3) S(1) 1;3 2 S(1); 2 S(3) S(2)]; C = A*...

12 years ago | 0

Answered
How to get the average of a subset of data in a matrix?
C = {'ItemA' 1 3 'ItemA' 2 5 'ItemA' 3 2 'ItemB' 2 4 'ItemB' 1 3 'ItemC' 2 9 'ItemC' 9 2}; [a,ii,ii] ...

12 years ago | 0

| accepted

Answered
How can I remove a word from an array?
xA=[0 4 2 1]; name={'person1' 'person2' 'person3' 'person4'}; [a,b] = unique(xA); out = name(b(end-1));

12 years ago | 0

| accepted

Answered
How to rearrange values in a matrix
xyz = [1 1 5 1 2 6 1 3 7 2 1 8 2 2 9 2 3 2]; out = nan(max(xyz(:,1:2))+1); out(2:end,1) = unique(xyz(...

12 years ago | 0

Answered
Choosing Specific Elements from An Array
[ii,jj] = ndgrid(1:5); k = abs(ii-jj)<=2; B = A.*(k&fliplr(k)); ADD A1 = A'; B = A1(k&fliplr(k));

12 years ago | 2

| accepted

Answered
rounding of the numbers in a array as per a condition
max(min(x,2),-2)

12 years ago | 1

| accepted

Answered
How to do the following in a simpler and smarter way?
kron(1:21,ones(1,12))

12 years ago | 1

Answered
Trouble with vectorization of the following code containing for loops and logical indexing
ai = bsxfun(@eq,Index(:)',reshape(aIndex,1,1,[])); di = bsxfun(@eq,Index(:),reshape(dIndex,1,1,[])); ii = bsxfun(@and,ai...

12 years ago | 2

| accepted

Answered
matrix iteration and subtraction
d = abs(bsxfun(@minus,y(:),s(:)'));

12 years ago | 0

| accepted

Answered
As I can solve the following problem binary
n = 4; idxend = 12; idx = idxend + bsxfun(@times,1-n:0,(1:n-1)');

12 years ago | 0

Answered
How to vectorize a "For Loop"
f=@(t,z) cos(t) .* z; t= linspace(0,3,100); z= linspace(0,10,1000); out = trapz(z(:),bsxfun(@(t,z)f(t,z),t(:)',z(:)))...

12 years ago | 0

| accepted

Answered
How to return a 2D matrix containing the heighest non-NaN values from a 3D matrix
s = size(M); [i1,i2] = ndgrid(1:s(1),1:s(2)); result = M(sub2ind(s,i1,i2,s(3) - sum(isnan(M),3))); ADD s = size(...

12 years ago | 0

| accepted

Answered
How to turn a matrix into a Multidimensional Array?
permute(A,[3 2 1]) or reshape(A.',1,size(A,2),[])

12 years ago | 1

| accepted

Answered
Subtraction for Matrix of Different Length
[a,b] = setdiff(x,y,'rows'); [~,ii] = sort(b); out = a(ii,:); or lb = ismember(x,y,'rows'); out = x(~lb,:);

12 years ago | 1

| accepted

Answered
calculated f(x) with a specific point x
f=@(x)exp(x.*(2-x.^2))-2./(3+5*x); x = 3/2; out = f(x); Please read about <http://www.mathworks.com/help/matlab...

12 years ago | 0

Answered
how to compare the value of a pixel with all other pixel?
M = randi(10,40,30); uM = unique(M); out = [uM, histc(M(:),uM)];

12 years ago | 0

| accepted

Answered
How to multiply two matrices together?
out = sum(cos(bsxfun(@times,A,reshape(B,1,1,[]))),3)

12 years ago | 0

Answered
Arranging two arrays in ascending order.
data = unique([A(:),B(:)],'rows'); ADD A = randi(20,8); B = randi([100 120],8); data = unique([A(:),B(:)],'row...

12 years ago | 0

Answered
Multiplying 2 matrices, using a for loop and storing results in a table.
[EDIT] X=[0.80;0]; t=pi/18; D=[cos(t) -sin(t); sin(t) cos(t)]; X(2,10) = 0; for jj = 2:size(X,2) X(:,jj)...

12 years ago | 1

| accepted

Answered
Error using integral function & function handles in a loop
z = abs(bsxfun(@minus,cc,mastercc)); xmin = bsxfun(@minus,mastercc,z); xmax = bsxfun(@plus,mastercc,z); p = 1./(maste...

12 years ago | 1

| accepted

Answered
Error in Numerical Integration, "Matrix dimensions must agree"
function myfun= test_integral(t) myfun= integral(@f,0,10,'ArrayValued',true); function fun=f(z) fun= cos(...

12 years ago | 0

| accepted

Answered
How can I interpolate this data?
z = [13.33333 1.92982 0.42105 15.26316 1.92982 0.42105 15.96491 2.01754 0.70175 14.21053 2.80702 1....

12 years ago | 1

| accepted

Answered
create a changing vector after each iteration
u = circshift(UM,[0 1]); a=[250 10 6 8 6]; va = bsxfun(@times,u,a); v2 = va; v2(v2==0) = inf; va=[va,v2];

12 years ago | 0

Answered
Vectorization of multiple embedded for loops
W = triu(squeeze(sqrt(sum(bsxfun(@minus,data,permute(data,[3 2 1])).^2,2))));

12 years ago | 2

| accepted

Answered
Remove redundancy values from matrix
A = unique(S).';

12 years ago | 0

Answered
How to insert a matrix to another matrix ?
A = (1:5)' B = randi(25,5); B(:,1) = A;

12 years ago | 0

Answered
save results after 3d matrix neighbourhood operation
result = blockproc(Image,[10 10],@(x)mean(reshape(x.data,[],1,size(Image,3))));

12 years ago | 0

Answered
How do I write a for loop to calculate the difference between two points?
Dist = zeros(size(A,1),1); for jj = 2:numel(Dist) Dist(jj) = sqrt(sum((A(jj,:) - A(1,:)).^2,2)); end or D...

12 years ago | 0

| accepted

Load more