MATLAB Answers

Removing data from matrix

17 views (last 30 days)
Hi, i have a set of n x 3 matrix. Such as A = [1 0 0;2 0 0 ; 3 0 0; 4 0 0 ]. I have my initial value, like [4 0 0 ]. I want to find my initial value from matrix and delete that row from my the matrix

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 22 Feb 2021
Edited: KALYAN ACHARJYA on 22 Feb 2021
One way:
int_dat=[4 0 0];
A =[1 0 0;2 0 0 ; 3 0 0; 4 0 0];
[r,c]=size(A);
idx=A==int_dat;
row_num=find(sum(idx')==c);
A(row_num,:)=[]
Result:
A =
1 0 0
2 0 0
3 0 0
  1 Comment
sooraj ajith
sooraj ajith on 22 Feb 2021
Thanks for clearing

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by