comparing table values using isequal
Mostra commenti meno recenti
Hi,
I have a table M. The second column contains either the letter 's' or letter 'f'.
I would like to put all the rows with the letter 'f' in the second column into a new table A with the following code
pocet_radku = height(M);
j=1;
for i=1:pocet_radku
TF = isequal ("M(i,2)",'f')
if TF == 1
A(j,:)= M(i,:);
j = j+1;
else
end
end
Unfortunatelly, the isequal function return only zeros. Any idea why? In there syntax error that I'm not aware of?
Testing in a command window:
>> isequal ("M(180,2)",'f')
ans =
logical
0
>> M(180,2)
ans =
table
Var2
_____
{'f'}
Thanks a lot for any answers
Risposta accettata
Più risposte (2)
Fangjun Jiang
il 15 Set 2020
Modificato: Fangjun Jiang
il 15 Set 2020
1 voto
try TF = isequal (M.Var2{i},'f')
1 Commento
Jakub Steiner
il 15 Set 2020
BOB MATHEW SYJI
il 15 Set 2020
0 voti
Instead of
TF = isequal ("M(i,2)",'f')
try,
TF = strcmp (M.2nd_variable,'f')
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!