필터 지우기
필터 지우기

load ascii data with multiple name

조회 수: 1 (최근 30일)
gugum gumbira
gugum gumbira 2016년 4월 13일
편집: Stephen23 2016년 4월 15일
dear all,
I have some data with name ZA000060.TXT, ZA000120.TXT, ZA000180.TXT ..... at the same time I load data with :
for k=60:60:300
aa = sprintf('%d',k);
load (['ZA0000' aa '.TXT'],'AAA')
end
but there is error when load second data because the zero number.
unable to read file "ZA0000120.TXT"
Any help would be great,
Best regard,
  댓글 수: 5
gugum gumbira
gugum gumbira 2016년 4월 15일
I got some errors with your syntax. would you please give full explanation about load the data into one variable
thanks
Stephen23
Stephen23 2016년 4월 15일
편집: Stephen23 2016년 4월 15일
You didn't replace the ellipses with the filename. Specify the filename and it will work.

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

채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 13일
for k=60:60:300
filename = sprintf('ZA000%03d.TXT', k);
ZA{K} = load(filename);
end
  댓글 수: 3
Guillaume
Guillaume 2016년 4월 13일
To elaborate on Walter's answer. We suspect the problem is that you need a variable number of 0s before the actual number, depending on the actual number of digits.
This is what the '%03d' does in the formatstring of sprintf. It says prints the number as decimal (the d) with at least 3 digits (the 3) padded by zeros if necessary (the 0).
gugum gumbira
gugum gumbira 2016년 4월 14일
Thanks alot :)

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by