Load a file by using a string in which the filename is stored

5 visualizaciones (últimos 30 días)
Rudy
Rudy el 1 de Mzo. de 2013
Comentada: ANKUR KUMAR el 8 de Oct. de 2017
I use these commands to create string with all names of the files that have a mat extension.
files = dir('*mat'); filenames = {files.name};
Now I want to load one of these files by just using a number
load(filenames(1)) or load filenames(1) or load('filenames(1)')
But none of these commands work. Any ideas?

Respuesta aceptada

Açmae
Açmae el 1 de Mzo. de 2013
Editada: Açmae el 1 de Mzo. de 2013
Hi Rudy -
'filename(1)' is a 1x1 cell in your case. In order to access the content of the cell, you would use curly brackets.
>> load(filename{1})
Cheers, Açmae

Más respuestas (1)

Rudy
Rudy el 3 de Mzo. de 2013
Thanks, that fixed it!!

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by