find a digit in string

2 次查看(过去 30 天)
Elysi Cochin
Elysi Cochin 2012-12-28
i have a folder named "inputImages" it contains 5 images named image1, image2 ... image5
i have a variable which contains a digit... if that digit contains in any of the names i want that image to get displayed in a figure...
example
variable=2; then image2.jpg should get displayed....
please can someone help me how to get the name of the image that contains the digit....

采纳的回答

Matt J
Matt J 2012-12-28
name=['image' num2str(variable) '.jpg'],

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-12-28
variable=2
file=sprintf('image%d',variable)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by