Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は次のコードを持っています:
fonts = dir('fonts') strcmp('BELL.TTF'、fonts.name)
fonts = dir('fonts')
strcmp('BELL.TTF'、fonts.name)
ここで、dir('fonts')は33x1構造体を返します。ここで、各エントリには名前(文字列)、日付、およびその他のいくつかのものがあります。fonts.nameのタイプがわかりません(セル配列かどうか)。最終的な目標は、strcmpを使用してすべての名前を比較できるようにすることです。
fonts.name33個の個別の文字配列です。これらをセル配列に結合して、で使用できるようにしstrcmpます。
fonts.name
strcmp
コード内:
fonts = dir('fonts'); %# use curly brackets to combine the 33 strings into a cell array tf = strcmp('BELL.TTF',{fonts.name})
tffonts.nameは、次の値が等しい場合は常に1の論理配列です。'BELL.TTF'
tf
'BELL.TTF'