Tags
 IOS SQL HTML C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6

# How can I remove rows of a matrix in Matlab when the difference between two consecutive rows is more than a threshold?

By : Jassa Singh
Date : October 17 2020, 06:10 PM
hop of those help? One very simple filter from Mathematical morphology that you could try is the closing with a structuring element of size 2. It changes the value of any sample that is lower than both neighbors to the lowest of its two neighbors. Other values are not changed. Thus, it doesn't use a threshold to determine what samples are wrong, it only looks that the sample is lower than both neighbors:
code :
``````y = [5, 6, 1, 7, 3, 8]; % OP's second column

y1 = y;
y1(end+1) = -inf;              % enforce boundary condition
y1 = max(y1,circshift(y1,1));  % dilation
y1 = min(y1,circshift(y1,-1)); % erosion
y1 = y1(1:end-1);              % undo boundary condition change
``````
``````I = y1 - y < 3;
y1(I) = y(I);
``````

Share :

## how to remove only the desired row from the matrix and return the rest rows of a matrix using matlab

By : abdalrahman khodiry
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I want to get the output removing only a single row and returning rest rows using matlab. For eg: Consider a matrix , Try this, given your definitions of A and B
code :
``````C = A(B,:)
D = A(setdiff(1:size(A,1),B),:)
``````

## How to remove those rows of matrix A, which have equal values with matrix B in specified columns in Matlab?

By : Habiba
Date : March 29 2020, 07:55 AM
I hope this helps you . try using setdiff. for example:
code :
``````c=setdiff(a,b,'rows')
``````
``````c = setdiff(a,b,'rows','stable')
``````
``````[temp c] = setdiff(a(:,1:2),b(:,1:2),'rows','stable')
c = a(c,:)
``````
``````a(~ismember(a(:,1:2),b(:,1:2),'rows'),:)
``````

## remove rows of matrix in matlab

By : DragonbornTimeTravel
Date : March 29 2020, 07:55 AM
this will help Removing negative values from X:
You can either reassign X to a vector which only contains the values of X which are not negative:
code :
``````>> X = X(X>=0)
X =
2
3
5
``````
``````>> X(X<0) = []
X =
2
3
5
``````
``````>> y = y(X>=0)
y =
2
3
5
``````
``````>> y(X<0) = []
y =
2
3
5
``````
``````>> ind = X < 0;
>> X(ind) = []
X =
2
3
5
>> y(ind) = []
y =
2
3
5
``````

## R: Selecting first of n consecutive rows above a certain threshold value

By : Tony Pham
Date : March 29 2020, 07:55 AM
this will help The easiest way is to use the zoo library in conjunction with dplyr. Within the zoo package there is a function called rollapply, we can use this to calculate a function value for a window of time.
In this example, we could apply the window to calculate the minimum of the next three values, and then apply the logic specified.
code :
``````df %>% group_by(MRN) %>%
mutate(ANC=rollapply(ANC, width=3, min, align="left", fill=NA, na.rm=TRUE)) %>%
filter(ANC >= 0.5) %>%
filter(row_number() == 1)

#   MRN Collected_Date   ANC
# 1 001     2015-01-03 0.532
# 2 004     2014-01-03 0.500
``````
``````rollapply(1:6, width=3, min, align="left", fill=NA) # [1]  1  2  3  4 NA NA
rollapply(1:6, width=3, min, align="center", fill=NA) # [1] NA  1  2  3  4 NA
rollapply(1:6, width=3, min, align="right", fill=NA) # [1] NA NA  1  2  3  4
``````

## Remove all rows after a certain value in matlab matrix

By : Никита Иванов
Date : March 29 2020, 07:55 AM
will help you I have a MATLAB matrix that is 100,000x2 (100,000 rows, two columns) , Assuming your matrix is named A: