Extract Variable from Filename?
Mostrar comentarios más antiguos
Hi there,
I'm trying to write a reuseable function for a multitude of data points. My current filename when I download my data is:
sitename.yr.synth.daily.mat
Is there a straightforward way to extract the site name so that I can assign it to a column in the matrix? The year is already a column.
I will need to do this on hundreds of sites and years, so I don't want to code each site name by hand. I also need this so that I can match the site name with other classifications and generate unique file names.
Thanks a million!
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 29 de Mayo de 2013
Editada: Azzi Abdelmalek
el 29 de Mayo de 2013
file='sitename.yr.synth.daily.mat'
idx=strfind(file,'.')
site=file(1:idx(1)-1)
%or
file='sitename.yr.synth.daily.mat'
idx=regexp(file,'\.' ,'split')
site=idx{1}
1 comentario
Kate
el 29 de Mayo de 2013
Categorías
Más información sobre Predictive Maintenance Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!