How to import data from .txt file?

347 ビュー (過去 30 日間)
Benjamin Watson
Benjamin Watson 2016 年 4 月 13 日
コメント済み: Jan Babiuch-Hall 2022 年 5 月 3 日
Hi All,
Ive tried importing my data via this code;
Spill = importdata('Spill.txt');
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')
but it doesn't work as it says "Index exceeds matrix dimensions.". It needs to be inputted by code and not just the import button. Can someone help? Ive attached the .txt file

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 13 日
編集済み: Azzi Abdelmalek 2016 年 4 月 13 日
Spill1 = importdata('Spill.txt');
Spill=Spill1.data
T = Spill(:,1);
C = Spill(:,2);
plot(T,C)
xlabel('Time / Days');
ylabel('Concentration / ppb')

その他の回答 (2 件)

ghozy shalahuddin
ghozy shalahuddin 2019 年 10 月 10 日
vh

parham kianian
parham kianian 2020 年 9 月 2 日
I think it is much easier to use textread function. Following link describe in full detail how to use this function to import data from a text file:
  1 件のコメント
Jan Babiuch-Hall
Jan Babiuch-Hall 2022 年 5 月 3 日
Video unavailale :(

サインインしてコメントする。

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by