Answered
Extract elements of the array using any
A = [83 32 7 61 91 13 17 48 95 9 34 60 172 11 36 60 213 43 ...

10 years ago | 0

Answered
Combine cells of a {1,3} cell array.
A = {[75 267 294 317 462 549 580 656 668]; [131 242 300 341 451 491 575 597 724]; [72 154 213 270 282 39...

10 years ago | 0

| accepted

Answered
How to convert black and white image to a matrix 100 x 100 ?
c = [1 0 0 1 1 1 0 1 0 0] out = ~c*2-1

10 years ago | 0

Answered
How to combine vectors based on value?
B = [4 5 6 7; 0 0 0 0; 0 0 0 0; 0 0 0 0]; C = [0; 5; 4]; D = B; [ll,idx] = ismember(B(1,:),C); D(s...

10 years ago | 1

Answered
Row major order matrix
out = bsxfun(@plus,1:11:111,(0:10)') or out = reshape(1:121,11,[]); or out = zeros(11); out(:) = 1:121;

10 years ago | 0

Answered
I need to convert a number into its column name equivalent
z = 'A':'Z'; d = [1, 2, 27, 28, 14558]; ll = ceil(log(max(d(:)))/log(26)); bs = rem(floor(d(:)*26.^(1-ll:0)),...

10 years ago | 1

Answered
Average values for duplicates in (:,1)
[A,~,ii] = unique(B(:,1),'stable'); x = B(:,[2,3]); [a,b] = ndgrid(ii,1:2); A(:,2:3) = accumarray([a(:),b(:)],x(:))./...

10 years ago | 1

Answered
More effcient way to generate unit vector multiples (no for loop)?
unit_vecs = kron((1:d)',[I;-I]);

10 years ago | 0

| accepted

Answered
How to index random points from vector
faa([1,22:42])

10 years ago | 0

Answered
separate x, y coordinate in a matrix into two different matrices
cell2mat(cellfun(@(x)reshape(x,1,1,[]),C,'un',0))

10 years ago | 0

Answered
Creating Matrix Using Existing Matrix
n - size matrix full(spdiags(ones(n,1)*(0:2*n-1),1-n:n-1,n,n)) or rot90(hankel(0:n-1,n-1:2*n-2))

10 years ago | 0

Answered
How to find rows with multiple entries that are equal?
out = A(any(hist(A')==3),:);

10 years ago | 1

Answered
Check Position with for loop, not enough input arguments
checktakentest = @(x)any(x(:) == 1); spotTaken = checktakentest(tttArray);

10 years ago | 0

Answered
how to initialise a struct array with pairs?
out = num2cell(reshape(struct2cell(data),2,[])',2)

10 years ago | 1

Answered
Writing loops for vectors?
it is homework x = [1 -2 3 5 4 2]; x1=x; for ii = 1:5, if x1(ii) > x1(ii+1), x1(ii:ii+1) = x1([ii+1,ii]); end; e...

10 years ago | 0

Answered
How to replace a double in a array with a string (cell)?
A = [1 0 1 0 1 0 0 1 0 1 0 1]; out = cell(size(A)); out(A>0) = {'[apple]'};

10 years ago | 1

Answered
Converting to array index
Please attach small part of the your file: melbournewaterlevels.csv. date1 = [StrYear StrMonth]; level1 = Water.data; ...

10 years ago | 0

Answered
How to plot a against varying phi value
phi = (0:90)'; s = [0.95,1.0,1.1,1.2]; sd = sind(phi); plot(phi,bsxfun(@minus,sin(1./s).^2.*(1+s.^2+1),sd.*(sd+.75*co...

10 years ago | 0

Answered
I'm writing a function which takes a 3x3 matrix as input and gives an angle and a position vector as output.Position vector has 3 more output arguements. Please help me identify the mistake i have made.
function [th, kxz] = equi_axis_angle(var) th = acos((trace(var)-1)*.5); k = var - var.'; k = k(tril(ones(3),-1)>0).*[...

10 years ago | 0

Answered
find '1' in an array
[ii,~,~,v] = regexp(sprintf('%d',x(:)'),'1(1+)')

10 years ago | 0

Answered
If Else Statement for the rainfall data
[~,~,ii]=histcounts(data_of_daily_rainfall,[-inf,.5,1.1,inf]); y = 1:3; out = y(ii);

10 years ago | 0

Answered
Cumulative sum of rainfall
Use function of MATLAB - |conv2|: R = randi(45,20,1); % Let R - your data of rainfall out = conv2(R(:),ones(5,1)/5,'same...

10 years ago | 0

Answered
two variables with known values in equations; use loop in matlab
x=[3 1 4 2 1]; y=[3 4 5 1 1]; z=[2 2 1 2 2]; d=x+y+2*z; e=2*d+x.*y.*z;

10 years ago | 1

| accepted

Answered
Count the number of occurrences of elements in second column
[~,~,a]=unique(Activities(:,2)); b = histc(a,1:a(end)); Result = b(a);

10 years ago | 0

| accepted

Answered
converting binary to hexadecimal
b = {'1100100101111111101';'1100000011001'}; out = dec2hex(bin2dec(b));

10 years ago | 1

Answered
Sum of matrix elements
B = sum(A(:,[2,4]),2);

10 years ago | 1

| accepted

Answered
Extract rows in 3D matrix according to indexes
% Let X - your data with size (60x100x40000) % ii - your vector with index of columns X from each frame of X (1x46000) ...

10 years ago | 1

| accepted

Answered
Extracting data from an array
x = arrayfun(@(x)randi(56,randi([12 13]),2),(1:69)','un',0); % x - your array n = cellfun(@(x)size(x,1),x); nm = ma...

10 years ago | 0

Answered
How to change the matlab default ans?
get_sign = @(x)x < 0

10 years ago | 0

Answered
How to Sum matrix diagonals
sum(diag(a(:,end:-1:1))); or summing all diagonals: sum(spdiags(rot90(a)));

10 years ago | 0

| accepted

Load more