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

 Réponse acceptée

KL
KL le 4 Sep 2017
Change 'headerlines' count to 3
c = textscan ( fid, '%n %n %n %n','headerlines',3,'delimiter',',');

1 commentaire

KL
KL le 4 Sep 2017
Modifié(e) : KL le 4 Sep 2017
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by