How can I plot a graph within a certain range?

3 views (last 30 days)
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...]

Accepted Answer

Yasasvi Harish Kumar
Yasasvi Harish Kumar on 5 Mar 2019
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 Comments
Walter Roberson
Walter Roberson on 6 Mar 2019
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.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!