Using strfind with inputs and outputs

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.

Respuestas (1)

Ameer Hamza
Ameer Hamza el 30 de Nov. de 2020

0 votos

See fileparts(): https://www.mathworks.com/help/matlab/ref/fileparts.html. It is easier to use for this question.

2 comentarios

Liz
Liz el 30 de Nov. de 2020
I am still not sure how to complete the question from this page.
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

Liz
el 30 de Nov. de 2020

Comentada:

el 30 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by