Textread in delimiter tab

14 次查看(过去 30 天)
Casey
Casey 2013-1-16
Hi I have a set of data in notepad. I am able to use excel to delimiter the data "tab" format in 3 separate columns. I wanted to do it in matlab, however I tried and unable to do it. The following data the example of the data that is being delimiter:
242.701118 69.972122 817904.7279
242.693033 69.977431 817903.6492
242.684942 69.982742 817902.5702
242.67685 69.98805 817901.4918
242.66875 69.99336 817900.413
242.66065 69.998667 817899.3348
242.652543 70.003977 817898.2563
242.644435 70.009284 817897.1782
242.636321 70.014592 817896.0999
242.628205 70.019898 817895.0221
242.620082 70.025206 817893.944
242.611958 70.030512 817892.8664
242.603828 70.035819 817891.7884
242.595696 70.041124 817890.7111
242.587558 70.046431 817889.6333
242.579419 70.051735 817888.5562
242.571272 70.057041 817887.4787
242.563125 70.062345 817886.4017
242.554971 70.06765 817885.3244
242.546816 70.072953 817884.2477
The code that I tried to type in:
[x,y,z] = textread(fid,'delimeter','\t');
is my code wrong in which areas?

回答(1 个)

Walter Roberson
Walter Roberson 2013-1-16
textread() takes a file name as its first argument, not a file identifier. textscan() takes a file identifier.
fid = fopen('YourFileName.txt', 'rt');
datacell = textscan(fid, '%f%f%f', 'delimiter', '\t');
fclose(fid);
x = datacell{1};
y = datacell{2};
z = datacell{3};

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by