필터 지우기
필터 지우기

Load different files then converting them into .txt files

조회 수: 1 (최근 30일)
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 13일
Hey everyone,
%%To load data from the (.mat) files and then convert them to (.txt) files
a=['20MIN_SCHJ300639_220208.mat' '20MIN_SEMS170640_040608.mat' '20MIN_SIMG200162_060208.mat'];
for i=1:3
fid = fopen('Data%i.txt', 'w');
load('a(i)');
fprintf (fid, '%.9f \r\n', data_block1);
fclose(fid);
end
I'm having an error in load('a(i)')!! How can I make it work?

채택된 답변

per isakson
per isakson 2012년 7월 13일
Make a a cell array of strings:
a={'20MIN_SCHJ300639_220208.mat' '20MIN_SEMS170640_040608.mat' '20MIN_SIMG200162_060208.mat'};
for i=1:3
fid = fopen('Data%i.txt', 'w');
load( a{i} );
fprintf (fid, '%.9f \r\n', data_block1);
fclose(fid);
end
  댓글 수: 7
Ryan
Ryan 2012년 7월 13일
What happens if you only load two files? (do you get data_block1 and data_block2 then?)
Yasmin Tamimi
Yasmin Tamimi 2012년 7월 14일
편집: Yasmin Tamimi 2012년 7월 14일
I loaded each one of the files separately to find the error!! So, I found 3 files out of the 70 that contain 3 data blocks. I removed them from the cell array and loaded them by themselves. I also found another error in the way I wrote my cell array, I fixed it and finally it worked properly!!

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 7월 13일

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by