How to delete the unwanted elements from a matrix based on certain assumptions of input character of 6-tuple input?

I have got the matrix of 729x6 elements. Each of the 729 elements are having 6 characters (i,j,k,l,m,n).
Also, I have certain initial conditions regarding these characters given and I want to delete the elements whose characters in the elements are not satisfying the initial conditions.
What coding, commands are required to carry out the task of applying initial conditions to the matrix of elements obtained in MATLAB?
The initial conditions include
i=0,1,2
k=1
l=1
m=1
Kindly tell. Thank you
I have attached the matrix of elements for ready reference.

 Akzeptierte Antwort

mask = ismember(ijklmn(:,1), [0, 1, 2]) & all(ijklmn(:,3:5) == 1, 2);
ijklmn = ijklmn(mask, :);

9 Kommentare

Thank you so much I have one more query What if initial conditions include
i=0,1,2
j=0,1
k=0,1,2
l=0,1
m=0,1
n=0,1
Kindly tell
regards surabhi
mask = ismember(ijklmn(:,1), [0, 1, 2]) & ismember(ijklmn(:,2), [0,1]) & ismember(ijklmn(:,3), [0, 1, 2]) & ismember(ijklmn(:,4), [0, 1]) & ismember(ijklmn(:,5), [0, 1]) & ismember(ijklmn(:,6), [0, 1]);
ijklmn = ijklmn(mask, :);
But this is showing the following output
mask = ismember(ijklmn(:,1), [0, 1, 2]) & ismember(ijklmn(:,2), [0,1]) & ismember(ijklmn(:,3), [0, 1, 2]) & ismember(ijklmn(:,4), [0, 1]) &
ismember(ijklmn(:,5), [0, 1]) & ismember(ijklmn(:,6), [0, 1]);
> ijklmn = ijklmn(mask, :)
Index exceeds matrix dimensions.
What should I do?
Kindly suggest
Before execution of the lines, please show size(ijklmn) . After execution of the first line, please show size(mask) and max(mask)
I meant to show them to us, so that we could help you find the problem.
Actually, Sir, I got the output by the code lines given by you. That's why I didn't write the code here again to you Thank you
So the code I had posted is working for you?
yes
But I am not getting expected outputs. I think it's might be I am taking wrong inputs for the same. I have to work upon the assumed inputs again and then try coding :(

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by