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

 채택된 답변

ANKUR KUMAR
ANKUR KUMAR 2018년 9월 29일

5 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

질문:

2018년 9월 29일

편집:

2018년 9월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by