当前位置: 动力学知识库 > 问答 > 编程问答 >

Matlab - Concatenate strings with wildcard

问题描述:

I have two variables, A and B, which have a variable between them that creates a file name. e.g.

A*B.mat where * %// can be any number of digits

Obviously dir A*B.mat does not work, but I haven't the faintest on how to actually make it work.

网友答案:

I think you want this: concatenate the contents of A and B with the string '*' in between and '.mat' at the end:

dir( [A '*' B '.mat'] )
网友答案:

You can use sprintf

dir( sprintf('%s*%s.mat', A, B ) );
分享给朋友:
您可能感兴趣的文章:
随机阅读: