Borrar filtros
Borrar filtros

Reading data from a title

3 visualizaciones (últimos 30 días)
Suzan Wulms
Suzan Wulms el 17 de Mayo de 2019
Comentada: Suzan Wulms el 20 de Mayo de 2019
I have a file name named Lek0_ServoU_C20_R40_PS8_14mei_1746.log, and want to put these parameters into a matrix with some values which come out of our first script. Is there an option that matlab reads this information out of the title from the file? So that we get a table with the column Lek, C and R and the different parameters underneath it?
  1 comentario
KSSV
KSSV el 17 de Mayo de 2019
Attach your file and explain us your expectations.

Iniciar sesión para comentar.

Respuesta aceptada

convert_to_metric
convert_to_metric el 17 de Mayo de 2019
Hi Suzan,
You can try using textscan to read data from the filename. It will be most straighforward if your filenames are consistent, for example:
files=dir('*.log');
leks=NaN(length(files),1);
Cs=leks;
Rs=leks;
for i=1:length(files)
out=textscan(files(i).name,'Lek%f_ServoU_C%f_R%f')
leks(i)=out{1};
Cs(i)=out{2};
Rs(i)=out{3};
end
T=table(leks,Cs,Rs,'VariableNames',{'Lek','C','R'});
  1 comentario
Suzan Wulms
Suzan Wulms el 20 de Mayo de 2019
Thank you very much! This is exactly what we need!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables 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