Answered
How to assign vectors to existing vector
Let X - interval for input data in 'vector_2' X = [0, 15]; x = setdiff(X(1):X(2),vector_1); % input data newvector_2 = vector...

6 years ago | 0

Answered
List combinations and count how many it appears
YY = Y(W~=0,:); n = sum(YY>0,2); k = factorial(n)./factorial(n-2)/2; ie = cumsum(k); ib = ie - k + 1; zc = zeros(ie(end),2)...

6 years ago | 0

| accepted

Answered
Find values in a 3D array based on values in a seperate 3D array
lo = M_data == 1; [ii,jj,k] = ind2sub(size(M_data),find(lo)); output = [ii,jj,k,B_data(lo)];

6 years ago | 1

| accepted

Answered
Finding maximum value in a sequence
A = randi(1000,1,8); k = A(1); for ii = 2:numel(A) if k < A(ii) k = A(ii); end end

6 years ago | 0

| accepted

Answered
adding multiple arrays into one big array
s1 = size(A1); s2 = size(A2); s22 = max(s1(2),s2(2)); A = [A1,zeros(s1(1),s22 - s1(2));A2,zeros(s2(1),s22 - s2(2))];

6 years ago | 1

| accepted

Answered
How to stop finding a value once it has been attained? (Find function inside a loop)
Please read about break in while loop.

6 years ago | 0

Answered
How do I make a block diagonal matrix using blkdiag function for a N dimensions
C = repmat({A},n,1); out = blkdiag(C{:});

6 years ago | 1

| accepted

Answered
Looping through numbers in file and adding first two numbers then next two and so on
conv(A,[1,1],'valid') or b = movsum(A,2); out = b(2:end);

6 years ago | 0

Answered
How can i classify my data?
a = [ 0.47 15.905 8.434 14.018 1010.803 1458.32 148.46 0.34 18.346 8.282 16.443 1012.711 1460.69 140.41 0.4 17.45...

6 years ago | 0

| accepted

Answered
A doubt regarding a simple For loop indexing for certain rows only.
lo = a(:,3) == 4; ii = cumsum([0;diff(lo) == 1]).*lo; m = max(ii); ii(ii == 0) = m + 1; out = a(ii >= m,:);

6 years ago | 1

Answered
Coud anyone help me to solve the issue.
One variant: [m,n] = size(A); [~,ii] = sort(rand(m-1,n)); B = A(2:end,:); An = [A(1,:);B(ii + (m-1)*(0:n-1))];% ATTENTION! I...

6 years ago | 1

| accepted

Answered
Problem with matrices. Double and cell
for ii = 1:numel(CT) if ~iscell(CT{ii}) CT{ii} = num2cell(CT{ii}); end end T = cell2table(cat(2,CT{:})); w...

6 years ago | 1

| accepted

Answered
How to convert a table into a structure
t2 = varfun(@(x){x(:)'},T,'GroupingVariables','Name'); TinStrr = t2(:,[1,3:end]); TinStrr.Properties.VariableNames = T.Propert...

6 years ago | 1

| accepted

Answered
How to manipulate a matrix under certain conditions to fills gaps with numbers.
Let MM - your 'required colum'. MM =[3,3,0,0,3,3,0,0,0,3,3,0,0,3,3,0,0,3,0]'; m = MM; m(m == 0) = nan; %lo - define the ...

6 years ago | 1

| accepted

Answered
how to fill gaps of rows with 3s of a matrix under certain conditions.
Let M = [0 0 3 3 0 0 0 3 0 0 0 0 3 0 3 0 3 0 ...

6 years ago | 1

| accepted

Answered
convert array 3d array into 3 column(ranked)
SPEED=[1 2]' TRQ=[10 20 30] Z=[0 1;3 5; 4 3] [x,y] = ndgrid(TRQ,SPEED); T = array2table([y(:),x(:),Z(:)],'VariableNames',{...

6 years ago | 1

| accepted

Answered
How do I generate multiple binary matrices containing a single one in each row?
May be so? m = 8; n = 6; % [m,n] = size(A); k = 10; [~,Anew] = sort(rand(m,n,k),2);% here fixed M = Anew == 1;

6 years ago | 1

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

6 years 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;

6 years 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));

6 years 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...

6 years ago | 0

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

6 years ago | 2

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

6 years 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...

6 years 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:...

6 years 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);

6 years 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

6 years ago | 1

| accepted

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

6 years 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)

6 years ago | 0

| accepted

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

6 years ago | 0

Load more