Using strfind with inputs and outputs

2 次查看(过去 30 天)
Liz
Liz 2020-11-30
评论: Ameer Hamza 2020-11-30
The question is:
'write a function which takes as input a filename of the form name.asc and returns three new filenames, of the form name.mat, name.xls and name.jpg'
I know that I need to use the strfind function and replace the last three lettters using [], however I am not sure how to go about it.

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-11-30
See fileparts(): https://www.mathworks.com/help/matlab/ref/fileparts.html. It is easier to use for this question.
  2 个评论
Liz
Liz 2020-11-30
I am still not sure how to complete the question from this page.
Ameer Hamza
Ameer Hamza 2020-11-30
For example
filename = 'name.asc';
[~,name,ext] = fileparts(filename)
Now you have 'name' and 'asc' in seperate variables. You can combine name with any extension you want.

请先登录,再进行评论。

类别

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

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by