Convert from textread() to textscan()
3 views (last 30 days)
Show older comments
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
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.
Accepted Answer
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};
0 Comments
More Answers (0)
See Also
Categories
Find more on Text Data Preparation 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!