Answered
convert binary vector value into decimal
polyval(a,2)

12 years ago | 0

Answered
How to add a number to the negative values in a vector?
A = [1 4 5 2 -3 4 5 7 -6 -6]; t = A < 0; A(t) = A(t) - 180; ADD May be use the following: A = mod(A,180);...

12 years ago | 0

| accepted

Answered
How to count the number of consecutive numbers of the same value in an array
c = [1 1 1 2 2 1 1 1]; v = numel(c):-1:1; ii = [true,diff(c)~=0]; n = v(ii); t = [n(2:end)+1,1]; out = v - ...

12 years ago | 1

Answered
Reshape matrix with zero value
n = size(dist1); out = zeros(n-[1 0]); out(:)=dist(~eye(n)); out = out';

12 years ago | 1

Answered
sort matrix according to parity?
z = sortrows(a,1); out = zeros(size(a)); out(1:2:end,:) = z(z(:,3)==0,:); out(2:2:end,:) = z(z(:,3)==1,:);

12 years ago | 0

| accepted

Answered
Combining arrays to form indices
x(B+1)=-1; x(A)=1; out = A(1):B(end)+1; out = out(cumsum(x)>0);

12 years ago | 0

Answered
Subtracting the first element of each row from the rest of the row ?
A=[3.5,4.5;2.4,3.2]; out = bsxfun(@minus,A,A(:,1));

12 years ago | 1

| accepted

Answered
iterating a vector with a loop?
Data = []; while 1 % here use your function for evalution HF, calc_length and handle % ... Data = [Dat...

12 years ago | 0

Answered
what are steps to create a combination array ?
[~,~,c] = xlsread('E:\xlsfile1.xlsx'); c1 = c(3:end,:); ii = cellfun(@(x)all(~isnan(x)),c1); n = sum(ii); idx = bs...

12 years ago | 0

Answered
Vectorize operations referencing adjacent elements of a matrix
out = convn(matrix,cat(3,[0 0 0;0 -1 0;0 0 0],... [0 -1 0;-1 1 -1;0 -1 0],... ...

12 years ago | 0

| accepted

Answered
How can i remove empty cells and print only the nonempty cell in a cell array?
strcat(q1(end),q2(end)) ADD q1 = {'+ab' {} '+BD'}; q2 = {{} '+aC'}; q = [q1 q2]; out = cat(2,q{:}); o...

12 years ago | 0

Answered
Assigning New Matrix Elements Based On Comparing 2 Matrices
C = (A >= B) + (A == B);

12 years ago | 0

| accepted

Answered
error with 20x10 array in a function
function Cp = fcp( beta,lambda ) global ASE Vsal = polyval(conv([0.0003,-0.0044,-0.0479,1.085],... ...

12 years ago | 0

Answered
How to read data from txt file and to create a 2D matrix?
f = fopen('yourtextfile.txt'); c = textscan(f,'%d %d %f','HeaderLines',10,'CollectOutput',1); fclose(f); out = ac...

12 years ago | 0

| accepted

Answered
having trouble with for loops
out = 1; for ii = 2:1000 out = out + ii^2; end

12 years ago | 0

| accepted

Answered
Is possible put a vector as a diagonal of matrix ?
blkdiag(A,A,A) or A = [1 2]; n = 4; a1 = repmat({A},n,1); out = blkdiag(a1{:});

12 years ago | 0

Answered
how to delete adjacent entries from an array
ii = unique(bsxfun(@plus,find(A == 60),[-1 0 1])); out = A; out(ii(ii > 0 & ii <= numel(A))) = []; way with |Image Pr...

12 years ago | 0

Answered
Finding Consecutive True Values in a Vector
a0 = a(:); % input vector ii = strfind(a0',[1 0]); a1 = cumsum(a0); i1 = a1(ii); a0(ii+1) = -[i1(1);diff(i1)]; ...

12 years ago | 3

| accepted

Answered
am i using while loop the right way?
out = CROP_THIS; while min(size(CROP_THIS)) > 1 CROP_THIS = remove_edges_from_matrix_function( CROP_THIS,1 ); ...

12 years ago | 0

| accepted

Answered
Adding columns to matrix using circshift by auto incrementing
z=[0;1;2;3]; x = [z;z]; n = numel(z); out = x(bsxfun(@minus,(n+1:2*n)',0:n-1));

12 years ago | 0

Answered
How to calculate a trapezoid with 4x2 input array...
function [A, P] = otherTrapezoid(c) [~,i0] = sort(angle(bsxfun(@minus,c(2:end,:),c(1,:))*[1;1i])); cx = diff(c([1;i0(...

12 years ago | 0

Answered
nested loops of different dimension without using "for loops"
ct = cosd(tilt); p1 = cosd(15.*h(:))*cosd(delta); sb = bsxfun(@plus,cosd(Lat)*p1,sind(Lat)*sind(delta)); cb = cosd(as...

12 years ago | 0

| accepted

Answered
Replace zero in a matrix with value in previous row
l = A == 0; ii = bsxfun(@plus,size(A,1)*(0:size(A,2)-1),cumsum(~l)); out = A; out(l) = A(ii(l));

12 years ago | 1

Answered
Find at least 4 consecutive values less than 1 in an array
t = M<1&M>0; t1 = [true;diff(t(:))~=0]; idx=accumarray(cumsum(t1),(1:numel(M))',[],@(x){x}); ii = idx(t(t1)); out ...

12 years ago | 0

Answered
Why is this script so slow and how can i make it faster?
[i1,i2]=find(M<.5); c = num2cell(sortrows([i1,rem(i2-1,4)+1,ceil(i2/4)]),1); [x,y,z] = c{:}

12 years ago | 0

Answered
Find index of same values in array
find(ismember(a,u(n>1))) ADD a=[nan nan 12 3 5 9 8 7 12 NaN NaN 0 0 2 1 4 4 4] u=unique(a(~isnan(a))); n=histc(a...

12 years ago | 3

| accepted

Answered
Matrix Multiplications (Altar Output Matrix Size)
c1 = bsxfun(@times,A,B);

12 years ago | 0

| accepted

Answered
Using a cell array and a for loop
use struct array rat_cell = {'number', 'sex', 'weight', 'age', 'treatment', 1, 'M', 400, 4, 0}; a = reshape(rat_cell,5,[...

12 years ago | 1

Answered
using arrayfun for a function with multiple inputs
b1=0; e1=20; x = arrayfun(@(x1)Before(x1,b1,e1), your_structure)

12 years ago | 3

Answered
Scale 3D matrix by 10i
Yscaled = bsxfun(@times,Y,reshape(1:P,1,1,[])*10)

12 years ago | 0

Load more