Using strfind with inputs and outputs
Mostra commenti meno recenti
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.
Risposte (1)
Ameer Hamza
il 30 Nov 2020
0 voti
See fileparts(): https://www.mathworks.com/help/matlab/ref/fileparts.html. It is easier to use for this question.
2 Commenti
Liz
il 30 Nov 2020
Ameer Hamza
il 30 Nov 2020
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.
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!