名前付きインデックスのエラー回避について
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tnew = T({'A','B'},:)
上記のコードでtable内の同一の行名を表示させることが可能ですが、
同一の行名が存在しない場合には、エラーを引き起こします。
このエラーを回避する方法はありませんか?
0 commentaires
Réponse acceptée
Hernia Baby
le 22 Avr 2021
もしエラーが生じた場合、何かしらのアクションを取らせるのであればIf分を使います
load patients
T = table(Age,Gender,Height,Weight,Smoker,...
'RowNames',LastName);
A ={'Smith','Johnson'}; %存在する名前
B ={'Smith','Hernia Baby'}; %存在しない名前
% C = A;
C = B;
if sum(categorical(LastName) == C)
Tnew = T(C,:)
else
disp('False')
end
もし違う出力がほしい場合はコメント願います。
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!