フィルターのクリア

How to plot graph x,y for text file

27 ビュー (過去 30 日間)
Yasumin Mingmuang
Yasumin Mingmuang 2018 年 9 月 29 日
編集済み: Walter Roberson 2018 年 9 月 30 日
Hi! I want to plot graph but I don't read file from file txt.
This is my code.
import matplotlib.pyplot as plt
import numpy as np
with open('t.txt','r',encoding = 'utf8') as f:
data = f.read()
data = data.split('\n')
x = [float(raw.split()[0]) for raw in data]
y = [float(raw.split()[1]) for raw in data]
plt.plot(x,y,'ro')
plt.show()
And my data in text file, t.txt.
Please help me
Thankyou
  1 件のコメント
ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 29 日
The code in your question is python code.

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

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 29 日
A=load('test.txt');
plot(A(:,1),A(:,2))
  2 件のコメント
Yasumin Mingmuang
Yasumin Mingmuang 2018 年 9 月 29 日
Thank you. But I cann't run to code. Can you write all the code and run it for me?
ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 30 日
I didn't get you. Do you want me to run the code and give the figure.
Well, I am attaching the matlab figure, so that you can edit too from your matlab command window.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by