필터 지우기
필터 지우기

Reading data from a title

조회 수: 3 (최근 30일)
Suzan Wulms
Suzan Wulms 2019년 5월 17일
댓글: Suzan Wulms 2019년 5월 20일
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
KSSV
KSSV 2019년 5월 17일
Attach your file and explain us your expectations.

댓글을 달려면 로그인하십시오.

채택된 답변

convert_to_metric
convert_to_metric 2019년 5월 17일
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
Suzan Wulms
Suzan Wulms 2019년 5월 20일
Thank you very much! This is exactly what we need!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by