importing text files via importdata

조회 수: 1 (최근 30일)
Philip Cung Van Ni Thangngat
Philip Cung Van Ni Thangngat 2019년 9월 24일
답변: Athul Prakash 2019년 9월 27일
I have a task saying that I have to upload the two first columns in a text file using the importdata function? Anyone who knows how?

답변 (1개)

Athul Prakash
Athul Prakash 2019년 9월 27일
Try this: You may use the Import Data Tool to do it graphically. [Click: 'Home' Tab > 'Variable' section > 'Import Data' icon]. In the Import Tool, you may modify the selected area to just the first two columns. Please select the output type too, to Table/ColumnVectors... etc. For full functionality, refer to the doc below:
If you're writing a script to do this, have a look at importdata, textscan, fscanf and similar functions. You may search the documentation for the same.
Alternatively, you may read all columns using importdata and then select out only the first two after that:
myData = importdata('YouFileName.txt');
myData = myData([1 2], :);

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by