Convert from textread() to textscan()

3 views (last 30 days)
I'm trying to update my code and was wondering if anyone can help with this simple question:
How would these two lines transfer over from textread() to textscan() in matlab?
[x,y,z]=textread(filename,'%f %f %f %*f %*f %*f','headerlines',3);
[X(:,k),Y(:,k),Z(:,k)]=textread(filenames,'%*f %*f %*f %f %f %f','headerlines',3);
  1 Comment
Jan
Jan on 17 Feb 2013
Please send an enhancement request to TMW and ask for not removing textread. There is no advantage in removing working commands.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 17 Feb 2013
Assuming the same file is being referenced for both:
fid = fopen(filename);
xyzcell = textscan(fid, '%f %f %f %f %f %f', 'HeaderLines', 3);
fclose(fid);
x = xyzcell{1};
y = xyzcell{2};
z = xyzcell{3};
X(:,k) = xyzcell{4};
Y(:,k) = xyzcell{5};
Z(:,k) = xyzcell{6};

More Answers (0)

Community Treasure Hunt

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

Start Hunting!