Hello, I wanted to ask about how you could call a Matlab file extension in name only , ie without the extension. For example, if I have a process or file " ejemplo.xml " , " ejemplo.wav " ... And I want to name , upload or read the file name "example" . For example , I want to process the following, using only the name "example" .
I have this file: " nombre.wav "
function res = function ( " name")
Or with a " audio.wav " file , use only the filename "audio" to create another name with that information.
Thanks in advanced.

 採用された回答

Adam
Adam 2016 年 5 月 17 日

0 投票

[pathstr,name,ext] = fileparts(filename);
breaks up a filename into component parts, including the name and the extension. I'm not really sure what you are asking, but if you get the 'name' part out of that then you can use this and it will be separated from the path and the extension.

5 件のコメント

Walter Roberson
Walter Roberson 2016 年 5 月 17 日
Once you have a name without extension, you can use [] or strcat() to add the extension. Like
name = 'example7';
[name '.wav']
Mario Martos
Mario Martos 2016 年 5 月 18 日
Thanks you very much!
Mario Martos
Mario Martos 2016 年 5 月 23 日
Hello, I wanted to ask about how I can remove a file extension because I have a function to call without the extension :
For example:
function[] = main (input)
Where input is an XML file , and after a process that file need to call in another function within it without the XML extension.
That would read:
function = first ( ' file.xml ');
and later that file without the extension in another function within the .m file as :
function[] = second ( 'file ' ) ,
here already without the .xml extension. Thanks in advanced!
Adam
Adam 2016 年 5 月 23 日
[pathstr,name,ext] = fileparts(filename);
newFilename = fullfile( pathstr, name );
assuming you only have one extension which you do.
Mario Martos
Mario Martos 2016 年 5 月 24 日
Thanks you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

タグ

質問済み:

2016 年 5 月 17 日

コメント済み:

2016 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by