About txt data plotting

1 回表示 (過去 30 日間)
大和 小島
大和 小島 2021 年 5 月 21 日
コメント済み: 大和 小島 2021 年 5 月 21 日
I want to read a txt data file and plot it. I want to plot the first column of the data as the x-axis and the second column as the y-axis. Please tell me how to write the code.
Sorry if my English is not good enough.
  2 件のコメント
Mike Mierlo van
Mike Mierlo van 2021 年 5 月 21 日
Hi YK,
I wrote a simple code for you that only works if your txt-file consists of numbers-only. For this problems just use Google like 'How to read data from a txt file in Matlab' and you'll find your answer.
My data.txt only contains two columns of numbers.
YourData = readtable('Data.txt'); % Read your .txt-file
YourData = table2array(YourData); % Convert the data from table format to matrix
figure(1)
plot(YourData(:,1),YourData(:,2)) % Plot your data
xlabel('First column in your txt-file')
ylabel('Second column in your txt-file')
大和 小島
大和 小島 2021 年 5 月 21 日
Hi.
Thanks for the quick comment.
I did the coding as in your example and it worked...
I'll be able to do better searches.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by