Answered
question about vectorization using indexes
ind(ind == 0) = 1; c = prod(a(ind).^b,2);

20 days ago | 0

Answered
How can I index a matrix using an array?
s = max(idx); A = false(s); A(sub2ind(s,idx(:,1),idx(:,2))) = true;

20 days ago | 1

Answered
Transform cells to matrix
S = scatteredInterpolant(A(:,1),A(:,2),A(:,3),A(:,4)); result = S(A(:,1),A(:,2),A(:,3));

20 days ago | 0

Answered
How to generate all collections of n subsets of 1:v?
v = 2; n = 3; s = 1:v; c = []; for ii = 1:v k = num2cell(nchoosek(s,ii),2); c = [c, k(:)']; end idx = fullfact...

20 days ago | 0

Answered
how to extract all variables from a struct
T = struct2table(data_table);

21 days ago | 2

Answered
movmax - remove duplicated
y = [2,3,4,5,4,3,2]; v = movmax(y,3); out = v(diff([0,v])~=0);

21 days ago | 0

Answered
How to use linear interpolation for filling with 3s inside empty spaces in a matrix of os and 3s
s = size(M); [a,b] = regexp(join(string(M)',''),'30+3'); jj = repelem(1:s(2),cellfun(@numel,a)); lo = zeros(s); lo(sub2ind(s...

21 days ago | 0

Answered
How to write elements of a nested cell array to an excel?
for old version of MATLAB n = cellfun(@numel,WC); k = cumsum(n); ii = k - n + 1; v = ones(k(end),1); v(ii(2:end)) = v(ii(2:...

22 days ago | 1

| accepted

Answered
Ouput value manupulation?
x_new = x.*(x > 0); or x_new = x; x_new(x_new <= 0) = 0; or xnew = max(x,0);

22 days ago | 1

| accepted

Answered
Matrix dimensions must agree.
function [z] = generateSin (a,f, ph,L, Fs) z = (a(:).*sin (2*pi*(0:L-1)/Fs).*f(:) + ph(:))'; end

22 days ago | 1

| accepted

Answered
change one column of matrix
A(index,:) = A(index,:) + B(index,:).*(A(index,:) ~= 0);

23 days ago | 1

Answered
Merge two matrices of different length with respect to a date
AB = outerjoin(array2table(A,'v',{'years','dataA'}),... array2table(B,'v',{'years','dataB'}),'MergeKeys',true)

24 days ago | 0

| accepted

Answered
How can i compare two columns ?
out = A(A => 3000);

24 days ago | 0

Answered
how to fill gaps in a matrix with a numbers using interpolation to develop a contour.
M(cumsum(M) & cumsum(M,1,'reverse')) = 3; or for: M =[0 0 0; 2 2 3; 3 3 0; 0 0 0; 3 3 0; 2 2 3; 0 0 0; 3 3 2; 0 0 0; 3 3 3]; ...

24 days ago | 1

| accepted

Answered
Delete rows with bad data and surrounding rows
ii - row indices with valid data (imdilate - function from the Image Processing Toolbox). ii = find(~imdilate(any(B,2),[1;1;1])...

25 days ago | 0

Answered
generate index for included subjects
temp.ids = 101:130; excl = 126:127; incl = ~ismember(temp.ids,excl); age = temp.age(incl);

26 days ago | 0

| accepted

Answered
How can I count specific value in one column but based on another four columns
Tout = varfun(@(x)numel(x),T,'g',1:4);

26 days ago | 1

| accepted

Answered
Mean value of equal cells
Let X - your cell array (2 x 9): out = mean(cat(1,X{2,:}));

26 days ago | 0

| accepted

Answered
From cell array to matrix
Y = cell2mat(cellfun(@(x)[x(:);zeros(4-numel(x),1)],X,'un',0));

26 days ago | 1

| accepted

Answered
Delete empty field - rows in a structure
out = Track_20(all(~cellfun(@isempty,struct2cell(Track_20))));

26 days ago | 1

Answered
[Help] If and ifelse condition
load('AC_Data.mat'); T = cell2table(AC); T.AC3 = str2double(T.AC3); T_out = fillmissing(T,'previous');

26 days ago | 0

| accepted

Answered
Reallocate values in matrix to even the values
n = size(Y); lo = ~eye(n); Y(lo) = max(Y(lo),5);

27 days ago | 0

| accepted

Answered
how to save double loop output in matrix form.
sm = conv2(thin_image,ones(3),'valid') imat = thin_image(2:end-1,2:end-1) == 1; ridge = sum(sm(:) == 1 & imat(:)); bifurcatio...

27 days ago | 0

Answered
How to use an array as an indexing table to add search result as a new row to the querying array ?
Q_new = [Q,Idx(discretize(Q,[Idx(:,1);Idx(end,2)]),3)];

27 days ago | 1

| accepted

Answered
How to create a matrix out of all the possible combinations of a vector
Please see answer by Roger Stafford. In your case: a = 3:5; v = [0,-1,1]; n = cumsum(a,'reverse'); C1 = nchoosek(1:n(1),a...

28 days ago | 1

| accepted

Answered
calculate area in table
T = readtable('Book1.xlsx'); out = varfun(@sum,T,'g','Class_Name');

29 days ago | 0

| accepted

Answered
Generating random variable from certain standard deviation and mean
a = .3;% standard deviation b = 0; % mean out = a.*randn + b;

1 month ago | 1

| accepted

Answered
Sub-Matrices in a bigger matrix
For matrices with the same size. Let [m,n] - size of each matrix, q - number of matrices in the vertical of a large matrix: M...

1 month ago | 0

Answered
For Loop Problem error
img=imread('C:\Users\Shalaw\Downloads\gray.jpeg'); [n,m]=size(img); imgs = mat2cell(img,[n,n]/2,[m,m]/2)'; for ii = 1:4 ...

1 month ago | 0

Answered
Calculate based on row
out = cellfun(@(x)-diff(x),your_cell_array,'un',0);

1 month ago | 1

| accepted

Load more