question about the textscan on a text file

I tried to use fopen the attached file, textscan, then reshape the matrix i used
fileid = ('filename.txt');
c = textscan ( fileid, '%n %n %n %n','headerlines',5,'delimiter',',')
the number of the elements that matlab read is 614, but my actual matrix from the text is 616. Is there any problem on my code

 Accepted Answer

Change 'headerlines' count to 3
c = textscan ( fid, '%n %n %n %n','headerlines',3,'delimiter',',');

1 Comment

c_matrix = cell2mat(c);
cc = reshape(c_matrix(:,1),22,28); %just one column
c_mat_nd = reshape(c_matrix,[22,28,4]); %all columns as ND matrix
This works for me!

Sign in to comment.

More Answers (0)

Asked:

on 4 Sep 2017

Edited:

KL
on 4 Sep 2017

Community Treasure Hunt

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

Start Hunting!