Answered
Vectorize calculating a co-variance matrix for every RGB pixel in an image
C = arrayfun(@(i1)xc(i1,:)'*xc(i1,:)*posterior(i1,count3),1:n,'un',0); individualSigma = cat(3,C{:}); However, one line ...

15 years ago | 0

Answered
To create an array of matrix of variable size
for ii = 46:-1:1, c{ii} = rand(randi([1 10],1,2)); end same without loop c = arrayfun(@(i1)rand(randi([1 20],1,2)),1:46,'u...

15 years ago | 1

| accepted

Answered
define variable-length matrix row sub-ranges using start and stop indices
Z = bsxfun(@times,vals,bsxfun(@le,pts,rand_max )); mcell= arrayfun(@(j1)Z(j1,ind_ini(j1):ind_end(j1)),(1:length(ind_ini))','...

15 years ago | 0

| accepted

Answered
How to assign variables.
h = .1:.1:.5; x = arrayfun(@(jj)h(jj:end),1:size(H,1),'un',0)

15 years ago | 0

Answered
generating monthly date series
use Financial Toolbox doc datemnth doc months COD: dated = {'01-Feb-2011','01-Nov-2015'}; t = datemnth(dated{1}, (0...

15 years ago | 0

Answered
subtracting a constant from all the array elements in a structure
V=squeeze(struct2cell(A)); V2 = arrayfun(@(x)cellfun(@(y)y-cons(x),V{x},'un',0) ,1:length(A),'un',0); A = struct('B',V2...

15 years ago | 0

Answered
Reshaping cell array having element with different sizes
A1 = A'; B = arrayfun(@(x)cat(1,A1{:,x}),1:size(A1,2),'un',0)

15 years ago | 1

| accepted

Answered
Finding maximum value, discounting a certain matrix place.
sweep(I) = NaN

15 years ago | 0

Answered
finding nearest label distance
1. coordinates of the nearest pixel [ii jj] = find((Md == mmn)&Ll); 2. number of labels nearest pixel out = L(ii,jj); 3....

15 years ago | 0

| accepted

Answered
finding nearest label
M = zeros(size(L)); M(4,1) = 1; Md = bwdist(M); Ll = logical(L); mmn = min(Md(Ll)); [ii jj] = find((Md == mmn)&Ll); ...

15 years ago | 0

| accepted

Answered
A second basic 'Find' question
I1 = find(data == X,1); X1 = data(I1:end) > Y; xf = find([true diff(X1)~=0]); idx = [xf; xf(2:end)-1 length(X1)]; idx(...

15 years ago | 0

Answered
Basic question: how to find range of index values
md = mydata==4; vf = find([true diff(md)~=0]); idx = [vf; vf(2:end)-1 length(md)]; indexsevenfour = idx(:,diff(idx)+1== ...

15 years ago | 0

Answered
reshuffle a symmetric matrix
1. sz = size(A); B = zeros(sz); vtl = nonzeros(tril(reshape(1:numel(A),sz))); B(tril(true(sz))) = A(vtl( randperm(lengt...

15 years ago | 3

| accepted

Answered
Finding integers in an array.
l = isnumeric(V)&rem(V,1)==0; ii = find(l,1,'first'); % 2 ValInt = V(ii); % 1 and 3

15 years ago | 0

Answered
Given a vector of assorted positive integers, how to create a vector with the means of every 2 integers inserted between each other?
m2 = v([2:end,end]); m3 = [v;m2]; vmeans = mean(m2); EDIT vout = reshape([v;conv(v,[1 1],'valid')/2 0],1,[]); vout =...

15 years ago | 0

Answered
assigning matrices to a cell
help: doc all doc function_handle doc arrayfun cod: l1 = all(X,2); X1 = X(l1,:); r1 = r(l1,:)==1; Bla_2 = arr...

15 years ago | 0

| accepted

Answered
output of code words
format short g

15 years ago | 1

Answered
column addding
y = [1 2 5 3 5 7 2 6 4]; x = [1 -2 7 3 5 4 2 -6 2]; z = sum(reshape((x-y).^2,3,[]));

15 years ago | 0

| accepted

Answered
column wise adding
doc reshape doc sum yout = sum(reshape(y,3,[])); EDIT z = sum((x-y).^2,2);

15 years ago | 0

Answered
dividing stream
doc reshape yout = reshape(y,3,[])';

15 years ago | 0

| accepted

Answered
Approximately equal or egual to +- error
u(abs(v - u)<=e) index idx = find(abs(v - u)<=e)

15 years ago | 6

Answered
Use of 3D array. Find inverse of individual page
function J =Jacobian1(t) global l1 l2 l3; j1 = [-(l1+l2.*cos(t(2,:))+l3.*cos(t(2,:)+t(3,:))).*sin(t(1,:)); -...

15 years ago | 0

| accepted

Answered
selecting random
x = rand(1,10e6); I = randperm(10e6); xout = x(I(1:1e4));

15 years ago | 0

Answered
complex polynomials
symbolic toolbox (MuPAD) syms t w expr=exp(1i*t*w*2)*exp(1i*t*w*3); result = evalin(symengine,['simplify(' , char(expr),'...

15 years ago | 0

| accepted

Answered
How can I create a function which evaluate only strings which represent only mathematical functions?
how Matt insertfunction='cos(2*pi*t)'; gh=symvar(insertfunction); f = str2func(['@(',gh{:},')',vectorize(insertfunct...

15 years ago | 1

Answered
Matrix Filtering
for our case [m,n]=size(A); II = mat2cell(A,m,ones(1,n)); I3 = nchoosek(1:n,2); jj = I3(arrayfun(@(x)all(xor(II{I3...

15 years ago | 0

Answered
Symbolic Math Toolbox VS MuPAD: example in advance of the first?
in MuPAD expand(subs(exp(log(10,x)),log(10,x)=ln(x)/ln(10))); EDIT rewrite(exp(log(10,x)),ln)

15 years ago | 0

Load more