Hi, I need to open a data file several times and import the data. In a loop I use the following:
temp2 =importdata('C:\Tmp2.txt', DELIMITER);
data2(i)= temp2;
fid = fopen('C:\Tmp2.txt');
temp = textscan(fid,'%*s %d %d %d %d',4,'headerlines',4,'delimiter','\t');
data4(:,:,i)=cell2mat(temp)
Im not sure of the syntax to clear data4 as sometimes if i run again and the number of loops "i" is lower than previous, it keeps data from the previous execution. Any help would be greatly appreciated

댓글 수: 4

Oleg Komarov
Oleg Komarov 2011년 5월 4일
Not clear why would you want to wipe the content off.
Post the loop please to understand why happens what you said.
Jason
Jason 2011년 5월 4일
There are typically 10 data files (all with the same name but with the content changing) that I want to access and plot. I use the "page" dimension of data4 to store all 12 data sets.
Once i have plotted this, then I might want to start all over again for and look at data for another experiment
Oleg Komarov
Oleg Komarov 2011년 5월 4일
clear data4?
Jason
Jason 2011년 5월 4일
Excellent, it was this that I was after - so simple!

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

 채택된 답변

Robert Cumming
Robert Cumming 2011년 5월 4일

0 개 추천

I "think" you could replace the line:
data4(:,:,i)=cell2mat(temp)
with
data4(:,:,(1:length(temp))=cell2mat(temp)
but its not very clear what your trying to do...

추가 답변 (0개)

카테고리

태그

Community Treasure Hunt

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

Start Hunting!

Translated by