2

I have the following code:

fonts = dir('fonts')

strcmp('BELL.TTF',fonts.name)

where dir('fonts') returns a 33x1 struct where each entry has name (string), date, and a few other things. I can't figure out what type fonts.name is (if it's a cell array or what), and my end goal is to be able to use strcmp to compare across all of the names.

Community
  • 1
  • 1
Hanmyo
  • 543
  • 4
  • 8
  • 18

1 Answers1

4

fonts.name is 33 separate character arrays. You want to combine these into a cell array so that you can use it with strcmp.

In code:

fonts = dir('fonts');
%# use curly brackets to combine the 33 strings into a cell array
tf = strcmp('BELL.TTF',{fonts.name})

tf is a logical array with 1 wherever fonts.name is equal to 'BELL.TTF'

Jonas
  • 74,690
  • 10
  • 137
  • 177