Filter löschen
Filter löschen

How can I plot a graph within a certain range?

3 Ansichten (letzte 30 Tage)
Víctor García
Víctor García am 5 Mär. 2019
Kommentiert: Walter Roberson am 6 Mär. 2019
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...]

Akzeptierte Antwort

Yasasvi Harish Kumar
Yasasvi Harish Kumar am 5 Mär. 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 Kommentare
Víctor García
Víctor García am 6 Mär. 2019
Thank you! it really helped me a lot :)
Walter Roberson
Walter Roberson am 6 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by