Answered
c row matrix corresponding to the minimum value of the distance of the matrix
m = 3; t = [1 0 0; 0 (1/sqrt(2)) (1/sqrt(2))]; v1 = 0.24; v2 = 0.956; a = [ 1 1 0]; b = [0 1 0]; p...

9 years ago | 0

| accepted

Answered
store matrix and the row matrix that corresponds to the smallest distance?
f =[2 1 1]; m =3; A =[ 1 0 0]; B =[1 1 0]; D =B-A; d1 =m*A; C =bsxfun(@plus,d1,(0:m)'*D); h = C*f'; [~...

9 years ago | 0

Answered
How to put different arrays in one big array?
D = {A,B,C}; s = cellfun(@numel,D); m = max(s); n = numel(D); out = zeros(m,n); for ii = 1:n out(1:s(ii),i...

9 years ago | 0

Answered
how to store the matrix from for loop?
m=3; A=[ 1 1 0]; B=[0 1 0]; D=B-A; d1=m*A; C = d1 + (0:m)'*D; % R2016b and later C = bsxfun(...

9 years ago | 1

Answered
How to get average of an array except considering the last element of the array
Let |A| - your double array B = A(:); out = mean(B(1:end-1));

9 years ago | 0

| accepted

Answered
Trying to find the x-intercept near 21.
>> y = @(x)x./7+cos(x./7-4)+exp(x./7-4)-4; >> x0 = 21; >> x_intercept = fzero(y,x0) x_intercept = 21.291 or ...

9 years ago | 0

Answered
error message:in an assignment A(i) =b the number of elements in b and i must be same
im = imread('peppers.tif'); a = double(im); new = mean(a,3); % if you use R2016b and later new1 = sum(a.*resha...

9 years ago | 0

Answered
how to convert m*n binary matrix to a*b matrix?
Let |a| - your char (or double) array with size: (18 x 8) b = rot90(reshape(a',[],2),1); inverse transformation ...

9 years ago | 0

Answered
double integral function error
fun1 = @(x,y)(-x.^2); fun2 = @(x,y)(y+1).^2; fun = @(x,y)fun1(x,y)+fun2(x,y); q = integral2(fun,0,100,0,50);

9 years ago | 0

Answered
how to convert m*n binary matrix to a*b matrix?
Let |a| - your char (or double) array with size: (18 x 8) out = rot90(reshape(a',[],2),1);

9 years ago | 2

| accepted

Answered
How to remove character in table
out = A(cellfun(@numel,A) == 1)

9 years ago | 0

Answered
How extract specific data from a large matrix and save in new matrix?
mv_ramp = a(ismember(a(:,1),mv),:);

9 years ago | 0

| accepted

Answered
How can i concatenate array of 3 to form single matrix?
[xx,yy,zz] = ndgrid(x,y,z); res = xx+yy+zz

9 years ago | 0

Answered
sortrows not working with logical column
[~,~,c]=unique(TCRes(:,1)); [~,ii] = sortrows([c,reshape([TCRes{:,2:3}],[],2)],[-2,1,3]); out = TCRes(ii,:);

9 years ago | 0

Answered
Insert an array into another array in a specific location.
A =[10 20 30]; B = [1 2 3 4 5 6 7 8 9]; c = 2; n = numel(A); k = c*n; B0 = [reshape(B(1:k),c,[]);A]; out = [B0...

9 years ago | 0

Answered
Assigning Random Weights at each Loop Iteration
W = rand(1,11); DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W)

9 years ago | 0

Answered
function_handler matrix
fun = @(x)((px{1}(x)-px{2}(x)).^2+(py{1}(x)-py{2}(x)).^2).^.5;

9 years ago | 0

| accepted

Answered
How to remove zero sum row from matrix
A = A(:,sum(A(2:end,:))~=0);

9 years ago | 1

Answered
how to add a cell array in another cell array row wise?
Let A = randi(1000,1,64); B = randi(1000,64,1806); C = A(:)+B; % for R2016b and later C = bsxfun(@plus,A(:),B)...

9 years ago | 0

Answered
Question related to vectorized matrix operation.
My variants: For R2016b and later >> C2 = squeeze(sum((A(:,1:2) - permute(B,[3,2,1])).^2,2)) C2 = 1 8 2 ...

9 years ago | 1

Answered
Store value in Matrix
A = [1 2; 3 4]; out = tril(ones(numel(A),1)*reshape(A.',1,[]));

9 years ago | 0

Answered
Insert zeros in a vector
One of ways: A = [1 2 3 7 9 10 45 93 122 150]' ii = randi(3,numel(A),1); t = cumsum(ii) < numel(A); ii = ii(t)...

9 years ago | 0

| accepted

Answered
Moving window with cumulative sum less than a ref value and excluding certain windows
I'm corrected, thank you Jan Simon. A= [ 0.5 0.6 .45 .56 .056 .16 .18 .10 .15 .45 .36]' ; out = zeros(numel(A),2); ...

9 years ago | 3

Answered
Distance between two points on the sphere.
Let |c| - your two coordinates ( |c = [x1 y1 z1; x2 y2 z2]| ), |r| - radius your sphere distance_out = 2*r*asin(norm(diff(c...

9 years ago | 2

Answered
Sorting files inside a folder
My small contribution x = regexp(C,'(\d+) (\d+)([ab])','tokens','once'); y = cat(2,x{:}); [~,ii] = sortrows([str2...

9 years ago | 1

Answered
How to save matrix created in each iteration
One of ways n=1; k=[1 2 3 4;5 6 7 8]; out = zeros([size(k),3]); while n<4 k=k*n; out(:,:,n) = k; ...

9 years ago | 1

| accepted

Answered
frequency of occurrence of the rows in a table
a = {'b2' 'YE' 'b2' 'YE' 'b5' 'HN' 'b5' 'HN' 'b6' 'NV'}; [a1,~,c] = unique(a,'stable'); cc = reshape(c,size(...

9 years ago | 1

| accepted

Answered
How to concatenate of results from a loop
X=[1 1;0 4;6 5]; [r,c] = find((1:size(X,1))'*(1:size(X,2)) > X); p = [r,c];

9 years ago | 1

Load more