How can I plot a graph within a certain range?

3 visualizaciones (últimos 30 días)
Víctor García
Víctor García el 5 de Mzo. de 2019
Comentada: Walter Roberson el 6 de Mzo. de 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...]

Respuesta aceptada

Yasasvi Harish Kumar
Yasasvi Harish Kumar el 5 de Mzo. de 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 comentarios
Víctor García
Víctor García el 6 de Mzo. de 2019
Thank you! it really helped me a lot :)
Walter Roberson
Walter Roberson el 6 de Mzo. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by