How can I import one column of data from a txt file into a variable?

52 ビュー (過去 30 日間)
Danielle Blicker
Danielle Blicker 2019 年 4 月 25 日
回答済み: Mark Sherstan 2019 年 4 月 25 日
How can I import one column of data from a text file into a variable?
I want to import the second column of data from a file called "MyData"
A =importdata('MyData.txt');
f = A.data(:,2);
The following error message appears:
Dot indexing is not supported for variables of this type.
Error in Lab3 (line 3)
f = A.data(:,2);
The column I want to import is a column of numbers (ex. 0.4963)
Thank you in advance!!

回答 (1 件)

Mark Sherstan
Mark Sherstan 2019 年 4 月 25 日
Try without the "."
A = importdata('myData.txt');
f = A(:,2)
I also included my .txt file in case you have your set up differently.

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by