开发者

File Extension in Matlab

开发者 https://www.devze.com 2023-02-13 23:28 出处:网络
Is there any way to get extension of a file from its filename ?? The only algo I could develop to do the above task is to find last \'.\' and rest all str开发者_运维百科ing to end..

Is there any way to get extension of a file from its filename ?? The only algo I could develop to do the above task is to find last '.' and rest all str开发者_运维百科ing to end..

But not too sure how to get index of final '.' from the given string..

Any new idea or suggestion for the same ??

I'm actually trying to develop a filter which only does processing on all image files rather than other non image file... Is there any other way of doing the same using any inbuilt function ???


Use the built in function "fileparts".


You can use the regexp function with the split parameter

output = regexp(your_string, '\.', 'split')

The output is a cell array that you can pull the value you want out of.

http://www.mathworks.com/help/techdoc/ref/regexp.html

0

精彩评论

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