MATLAB Opening text files and storing data 4 3 1 10 2 30 3 2

MATLAB Opening text files and storing data

4   3      
1   10      
2   30
3   20
4   0
1   4 1      
2   1 3
3   3 2
1.e7   1.339   .5      
4          
1 5 3 4          
1          
7   5.0  

How can I open this text file and convert selected rows and store them into vectors i.e. if I only want rows 3-7 in the text file I will have a vector that has the following rows.

2   30
3   20
4   0
1   4 1      
2   1 3

I also need to make sure that the data collected is floating point and 8 byte

Solution

vector1 = rand(10,10);
vector2=rand(10,10);
fileID = fopen(\'sample.dat\');
C = textscan(fileID,\'%f8 %f8\');
fclose(fileID);
m=1;
for i=3:7
vector1(m)=C(i)(1)
vector2(m)=C(i)(2)
m=m+1
end

MATLAB Opening text files and storing data 4 3 1 10 2 30 3 20 4 0 1 4 1 2 1 3 3 3 2 1.e7 1.339 .5 4 1 5 3 4 1 7 5.0 How can I open this text file and convert se

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site