开发者

MATLAB: struct.name type and strcmp

I have the following code:

fonts = dir('fonts')

strcmp('BELL.TTF',font开发者_Go百科s.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.


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'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜