Using strfind with inputs and outputs

조회 수: 1 (최근 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