How can I plot a graph within a certain range?

2 次查看(过去 30 天)
I am new to Matlab and I've been plotting for a while, but now I would like to plot 100 specific samples obtained from a temperature sensor within 100 seconds.
y=[20.50,20.50,20.50,20.50,20.50,20.50,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.620.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.70,20.70,20.60,20.60,20.70,20.70,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20 60,20.60,20.60,20.60,20.60,20.60,20.60,20.50,20.50,20.50,20.50,20.40,20.40,19.80,19.80,19.00,19.00,18.40,18.40,18.20,18.20,17.80,17.80,17.30,17.30,16.90,16.9 16.60,16.60,16.30,16.30,16.20,16.20,16.20,16.20,16.00,16.00,15.60,15.60,15.40,15.40,15.10,15.10,14.60,14.60,14.40,14.40]
The Y-Axis would be "Temp
erature" and the X-axis would be "Time" which has a duration of 100 seconds. My question is how can I establish an X-axis of 100 values without having to write something like the Y-Axis 100 times:
x=[1,2,3,4,5,6,7,8,9...]

采纳的回答

Yasasvi Harish Kumar
Hi,
This should fix your problem,
y=[20.50,20.50,20.50,20.50,20.50,20.50,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.620.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.70,20.70,20.60,20.60,20.70,20.70,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20.60,20 60,20.60,20.60,20.60,20.60,20.60,20.60,20.50,20.50,20.50,20.50,20.40,20.40,19.80,19.80,19.00,19.00,18.40,18.40,18.20,18.20,17.80,17.80,17.30,17.30,16.90,16.9 16.60,16.60,16.30,16.30,16.20,16.20,16.20,16.20,16.00,16.00,15.60,15.60,15.40,15.40,15.10,15.10,14.60,14.60,14.40,14.40];
x = 1:1:100;
plot(x,y)
Regards
  2 个评论
Walter Roberson
Walter Roberson 2019-3-6
Also, if you just plot(y) then MATLAB presumes that x is 1 : length(y) for vector y, and 1:size(y,1) for two or more dimensional y.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by