简体   繁体   English

如何在Octave中从已知的xs数组和ys数组绘制图形?

[英]How to plot graph from known array of xs and array of ys in Octave?

I need to draw several graphs for my report. 我需要为报告绘制几个图表。 How can I draw graph, if x and y pairs are saved in a file. 如果x和y对保存在文件中,如何绘制图形。 Is it possible to directly read values from file and draw a graph? 是否可以直接从文件中读取值并绘制图形? Example x,y pairs: 示例x,y对:

0.0 -0.1436521
0.2013266 -0.06703765
0.4026532 -0.08619126
0.60397977 -0.08619126
0.8053064 -0.10534488
1.0066329 -0.12449849
1.2079595 -0.095768064
1.4092861 -0.047884032
1.476395 -0.02873042
1.5099494 -0.06703765
1.5770583 -0.009576807
1.6106128 -0.038307227
1.6777216 -0.019153614

You can use load to read the data into an array, and plot to plot it. 您可以使用load将数据读取到数组中,然后进行plot以对其进行绘图。

For example (assuming the data file is called 'data.txt'), 例如(假设数据文件称为“ data.txt”),

octave:9> data = load('-ascii', 'data.txt')
data =

   0.00000  -0.14365
   0.20133  -0.06704
   0.40265  -0.08619
   0.60398  -0.08619
   0.80531  -0.10534
   1.00663  -0.12450
   1.20796  -0.09577
   1.40929  -0.04788
   1.47639  -0.02873
   1.50995  -0.06704
   1.57706  -0.00958
   1.61061  -0.03831
   1.67772  -0.01915

octave:10> plot(data(:, 1), data(:, 2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM