回答済み
Infinite for loop getting stuck. Creating a new column containing a variable.
kk = [data.NAPMPMIIndex > 50, data.AboveMA > .5]; g = findgroups(kk(:,1),kk(:,2)); a = [-1;1;-.5;.5]; data.signal = a(g);

19日 前 | 2

| 採用済み

回答済み
How can I code so: if a value on an array is false(0), and there is another false later on the list,all the 1's between (true) all the 1's turn into 0?
A = [0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0]; imerode(imdilate(A,[1 1 1]),[1 1 1]); or c = cumsum(A); cc = cumsum(A,'re...

20日 前 | 0

回答済み
Efficiently add cell value from a matrix row based on corresponding index to another matrix row
m = size(B,1); C = reshape(B,m,2,[]); C(:,end+1,:) = reshape(A(B(:,2:2:end),4),m,1,[]); C = reshape(C,m,[]); or m = size(B,...

22日 前 | 0

| 採用済み

回答済み
How select a first value from the binary matrix ?
out = cumsum(cumsum(matrix)) == 1; or out = cumsum(matrix) == 1 & matrix;

25日 前 | 1

| 採用済み

回答済み
How can I compare a set of variables?
x= [1; 3; 4; 3; 3; 1; 2] [~,~,c] = unique(x,'stable'); x_out = accumarray(c,x,[],@(x){x});

25日 前 | 1

回答済み
Sorting Table Data by Groups of Rows
Let T - your table with size (176120x5) and T(:,1) - the timestamp column. T{:,1} = fillmissing(T{:,1},'previous'); T_out = so...

25日 前 | 0

回答済み
How to change non zero value into 0?
Let A - your binary array (n x n) m = 10; B = cumsum(A); out = A.*(B(end,:) - m >= B);

26日 前 | 3

| 採用済み

回答済み
Find Number of Elements in an Array
A = {'KM'; 'KL'; 'MN'; 'KM'; 'MM'; 'KL'}; out = varfun(@x,table(A),'GroupingVariables','A')

27日 前 | 0

回答済み
Splitting one column into multiple columns
input = {'0.17 1.7285 0.001763792 1.000977 56651.41 0.000017652 DHT11, OK, 35.0,'; ...

約1ヶ月 前 | 1

回答済み
Resample datetime to minute resolution
T = fuel1(:,{'Start','Volume'}); T.Properties.VariableNames={'time','vol'}; T1=table; T1.time = fuel1.End; T1.vol = zeros(si...

約1ヶ月 前 | 1

| 採用済み

回答済み
How to organize a table?
T = readtable('img1.txt'); out = varfun(@sum,T,'GroupingVariables',... {'time','cell_type'},'InputVariables','cell_t...

約1ヶ月 前 | 0

回答済み
work with matrix of words and number
T = readtable('txtfile.txt') T_out = varfun(@mean,T,'GroupingVariables','Var1');

約1ヶ月 前 | 0

| 採用済み

回答済み
Interleaving Vectors in MATLAB
Without loop: A = [1 2 4];B = [5 6 7]; C = [A;B]; C = C(:)'; with loop: for ii = numel(A):-1:1 C(2*ii-[0 1]) = [B(i...

約1ヶ月 前 | 0

回答済み
To generate alternate 0's and 1's
out = repelem(mod(0:numel(A)-1,2),A);

約1ヶ月 前 | 6

| 採用済み

回答済み
Data filtering(Cut from half length of index until next index )
data2 = data(cell2mat(accumarray(data(:,1),... (1:size(data,1))',[],@(x){x(1:ceil(numel(x)/2))})),:);

約1ヶ月 前 | 2

| 採用済み

回答済み
Manipulate matrix of different dimension
mm = [0 0 1;1 2 5;0 2 3 ;0 3 4; 0 4 5]; m = size(mm,1); n = max(mm(:)); lo = eye(m,n) ~= 0; M = zeros(m,n); [ii,~,v]=find...

約1ヶ月 前 | 0

| 採用済み

回答済み
Double = in one line of code
b = 1000; zz = {b}; [a,c] = zz{[1,1]};

約1ヶ月 前 | 2

回答済み
Matrix calculation indexing conditional
Let A - your array (500 x 6): T = array2table(A); T_out = varfun(@sum,T,'InputVariables',2,'GroupingVariables',3:4);

約1ヶ月 前 | 0

| 採用済み

回答済み
Find a series of consecutive numbers and change index of them
[~,~,Data(:,1)] = unique(cumsum(Data(:,1)) - Data(:,2),'stable');

約1ヶ月 前 | 1

回答済み
How to apply a matlab code on a matrix if it already working on column vector.
[r,c] = size(MM); m = MM; m(m == 0) = nan; %lo -define the indices of the values that need to be changed: lo = fillmissing(...

約1ヶ月 前 | 1

| 採用済み

回答済み
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...

約1ヶ月 前 | 0

回答済み
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)...

約1ヶ月 前 | 0

| 採用済み

回答済み
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)];

約1ヶ月 前 | 1

| 採用済み

回答済み
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

約1ヶ月 前 | 0

| 採用済み

回答済み
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))];

約1ヶ月 前 | 1

| 採用済み

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

約1ヶ月 前 | 0

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

約1ヶ月 前 | 0

| 採用済み

回答済み
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);

約1ヶ月 前 | 0

回答済み
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...

約1ヶ月 前 | 0

| 採用済み

回答済み
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,:);

約1ヶ月 前 | 1

Load more