Clearing data

4 views (last 30 days)
Jason
Jason on 4 May 2011
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 Comments
Oleg Komarov
Oleg Komarov on 4 May 2011
clear data4?
Jason
Jason on 4 May 2011
Excellent, it was this that I was after - so simple!

Sign in to comment.

Accepted Answer

Robert Cumming
Robert Cumming on 4 May 2011
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...

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!